Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Classes for MediaType and proper converters of Http values fromto parameters or requestresponse bodies.
Synopsis
- data MediaType
- class ToMediaType a where
- class ToMediaType ty => ToRespBody ty b where
- toRespBody :: b -> ByteString
- data Json
- data FormUrlEncoded
- data OctetStream
- data AnyMedia
- class ToMediaType ty => FromReqBody ty b where
- fromReqBody :: ByteString -> Either Text b
Documentation
An HTTP media type, consisting of the type, subtype, and parameters.
Instances
IsString MediaType | |
Defined in Network.HTTP.Media.MediaType.Internal fromString :: String -> MediaType # | |
Show MediaType | |
Eq MediaType | |
Ord MediaType | |
Defined in Network.HTTP.Media.MediaType.Internal | |
Accept MediaType | |
Defined in Network.HTTP.Media.MediaType.Internal parseAccept :: ByteString -> Maybe MediaType # matches :: MediaType -> MediaType -> Bool # moreSpecificThan :: MediaType -> MediaType -> Bool # | |
RenderHeader MediaType | |
Defined in Network.HTTP.Media.MediaType.Internal renderHeader :: MediaType -> ByteString # | |
HasContentType Encoding (Maybe MediaType) | |
Defined in Data.OpenApi.Lens | |
HasContent RequestBody (InsOrdHashMap MediaType MediaTypeObject) | |
Defined in Data.OpenApi.Lens | |
HasContent Response (InsOrdHashMap MediaType MediaTypeObject) | |
Defined in Data.OpenApi.Lens |
class ToMediaType a where Source #
Conversion of type-level tags to media type values
Instances
ToMediaType Html Source # | |
Defined in Mig.Core.Class.MediaType | |
ToMediaType ByteString Source # | |
Defined in Mig.Core.Class.MediaType | |
ToMediaType AnyMedia Source # | |
Defined in Mig.Core.Class.MediaType | |
ToMediaType FormUrlEncoded Source # | |
Defined in Mig.Core.Class.MediaType | |
ToMediaType Json Source # | |
Defined in Mig.Core.Class.MediaType | |
ToMediaType OctetStream Source # | |
Defined in Mig.Core.Class.MediaType | |
ToMediaType Text Source # | |
Defined in Mig.Core.Class.MediaType |
class ToMediaType ty => ToRespBody ty b where Source #
Values that can be rendered to response body byte string.
toRespBody :: b -> ByteString Source #
Instances
Type-level tag for JSON media type It is converted to "application/json"
Instances
ToMediaType Json Source # | |
Defined in Mig.Core.Class.MediaType | |
FromJSON a => FromReqBody Json a Source # | |
Defined in Mig.Core.Class.MediaType fromReqBody :: ByteString -> Either Text a Source # | |
ToJSON a => ToRespBody Json a Source # | |
Defined in Mig.Core.Class.MediaType toRespBody :: a -> ByteString Source # |
data FormUrlEncoded Source #
Type-level tag for FORM url encoded media-type. It is converted to "application/x-www-form-urlencoded"
Instances
ToMediaType FormUrlEncoded Source # | |
Defined in Mig.Core.Class.MediaType | |
FromForm a => FromReqBody FormUrlEncoded a Source # | |
Defined in Mig.Core.Class.MediaType fromReqBody :: ByteString -> Either Text a Source # | |
ToForm a => ToRespBody FormUrlEncoded a Source # | |
Defined in Mig.Core.Class.MediaType toRespBody :: a -> ByteString Source # |
data OctetStream Source #
Media type octet stream is for passing raw byte-strings in the request body. It is converted to "application/octet-stream"
Instances
ToMediaType OctetStream Source # | |
Defined in Mig.Core.Class.MediaType | |
FromReqBody OctetStream ByteString Source # | |
Defined in Mig.Core.Class.MediaType | |
FromReqBody OctetStream ByteString Source # | |
Defined in Mig.Core.Class.MediaType fromReqBody :: ByteString -> Either Text ByteString Source # | |
ToRespBody OctetStream ByteString Source # | |
Defined in Mig.Core.Class.MediaType toRespBody :: ByteString -> ByteString0 Source # | |
ToRespBody OctetStream ByteString Source # | |
Defined in Mig.Core.Class.MediaType toRespBody :: ByteString -> ByteString Source # |
Signifies any media. It prescribes the server renderer to lookup media-type at run-time in the "Conten-Type" header. As media-type it is rendered to "*/*".
It is useful for values for which we want to derive content type from run-time values. For example it is used for static file servers to get media type from file extension.
Instances
ToMediaType AnyMedia Source # | |
Defined in Mig.Core.Class.MediaType | |
ToRespBody AnyMedia ByteString Source # | |
Defined in Mig.Core.Class.MediaType toRespBody :: ByteString -> ByteString0 Source # | |
ToRespBody AnyMedia ByteString Source # | |
Defined in Mig.Core.Class.MediaType toRespBody :: ByteString -> ByteString Source # |
class ToMediaType ty => FromReqBody ty b where Source #
Values that can be parsed from request byte string.
fromReqBody :: ByteString -> Either Text b Source #
Instances
FromForm a => FromReqBody FormUrlEncoded a Source # | |
Defined in Mig.Core.Class.MediaType fromReqBody :: ByteString -> Either Text a Source # | |
FromJSON a => FromReqBody Json a Source # | |
Defined in Mig.Core.Class.MediaType fromReqBody :: ByteString -> Either Text a Source # | |
FromReqBody OctetStream ByteString Source # | |
Defined in Mig.Core.Class.MediaType | |
FromReqBody OctetStream ByteString Source # | |
Defined in Mig.Core.Class.MediaType fromReqBody :: ByteString -> Either Text ByteString Source # | |
FromReqBody Text Text Source # | |
Defined in Mig.Core.Class.MediaType fromReqBody :: ByteString -> Either Text Text Source # |