| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Mig.Core.Class.MediaType
Description
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 Methods 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 Methods parseAccept :: ByteString -> Maybe MediaType # matches :: MediaType -> MediaType -> Bool # moreSpecificThan :: MediaType -> MediaType -> Bool # | |
| RenderHeader MediaType | |
Defined in Network.HTTP.Media.MediaType.Internal Methods renderHeader :: MediaType -> ByteString # | |
| HasContentType Encoding (Maybe MediaType) | |
Defined in Data.OpenApi.Lens | |
| HasContent RequestBody (InsOrdHashMap MediaType MediaTypeObject) | |
Defined in Data.OpenApi.Lens Methods content :: Lens' RequestBody (InsOrdHashMap MediaType MediaTypeObject) # | |
| HasContent Response (InsOrdHashMap MediaType MediaTypeObject) | |
Defined in Data.OpenApi.Lens Methods content :: Lens' Response (InsOrdHashMap MediaType MediaTypeObject) # | |
class ToMediaType a where Source #
Conversion of type-level tags to media type values
Methods
Instances
| ToMediaType Html Source # | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToMediaType ByteString Source # | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToMediaType AnyMedia Source # | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToMediaType FormUrlEncoded Source # | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToMediaType Json Source # | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToMediaType OctetStream Source # | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToMediaType Text Source # | |
Defined in Mig.Core.Class.MediaType Methods | |
class ToMediaType ty => ToRespBody ty b where Source #
Values that can be rendered to response body byte string.
Methods
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 Methods | |
| FromJSON a => FromReqBody Json a Source # | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text a Source # | |
| ToJSON a => ToRespBody Json a Source # | |
Defined in Mig.Core.Class.MediaType Methods 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 Methods | |
| FromForm a => FromReqBody FormUrlEncoded a Source # | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text a Source # | |
| ToForm a => ToRespBody FormUrlEncoded a Source # | |
Defined in Mig.Core.Class.MediaType Methods 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 Methods | |
| FromReqBody OctetStream ByteString Source # | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString0 -> Either Text ByteString Source # | |
| FromReqBody OctetStream ByteString Source # | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text ByteString Source # | |
| ToRespBody OctetStream ByteString Source # | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: ByteString -> ByteString0 Source # | |
| ToRespBody OctetStream ByteString Source # | |
Defined in Mig.Core.Class.MediaType Methods 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 Methods | |
| ToRespBody AnyMedia ByteString Source # | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: ByteString -> ByteString0 Source # | |
| ToRespBody AnyMedia ByteString Source # | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: ByteString -> ByteString Source # | |
class ToMediaType ty => FromReqBody ty b where Source #
Values that can be parsed from request byte string.
Methods
fromReqBody :: ByteString -> Either Text b Source #
Instances
| FromForm a => FromReqBody FormUrlEncoded a Source # | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text a Source # | |
| FromJSON a => FromReqBody Json a Source # | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text a Source # | |
| FromReqBody OctetStream ByteString Source # | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString0 -> Either Text ByteString Source # | |
| FromReqBody OctetStream ByteString Source # | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text ByteString Source # | |
| FromReqBody Text Text Source # | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text Text Source # | |