Safe Haskell | None |
---|---|
Language | Haskell2010 |
Servant.API
Contents
- Combinators
- Accessing information from the request
- Actual endpoints, distinguished by HTTP method
- Sub-APIs defined as records of routes
- Streaming endpoints, distinguished by HTTP method
- Authentication
- Endpoints description
- Content Types
- Response Headers
- Untyped endpoints
- FromHttpApiData and ToHttpApiData
- Experimental modules
- Links
- Re-exports
Synopsis
- module Servant.API.Sub
- module Servant.API.Alternative
- module Servant.API.Empty
- data Lenient
- data Optional
- data Required
- data Strict
- module Servant.API.Capture
- module Servant.API.Header
- module Servant.API.HttpVersion
- module Servant.API.QueryParam
- data DeepQuery (sym :: Symbol) a
- data QueryString
- module Servant.API.Fragment
- module Servant.API.ReqBody
- module Servant.API.RemoteHost
- module Servant.API.IsSecure
- module Servant.API.Vault
- module Servant.API.WithNamedContext
- module Servant.API.WithResource
- data StdMethod
- type Delete = Verb 'DELETE 200
- type DeleteAccepted = Verb 'DELETE 202
- type DeleteNoContent = NoContentVerb 'DELETE
- type DeleteNonAuthoritative = Verb 'DELETE 203
- type Get = Verb 'GET 200
- type GetAccepted = Verb 'GET 202
- type GetNoContent = NoContentVerb 'GET
- type GetNonAuthoritative = Verb 'GET 203
- type GetPartialContent = Verb 'GET 206
- type GetResetContent = Verb 'GET 205
- data NoContentVerb (method :: k1)
- type Patch = Verb 'PATCH 200
- type PatchAccepted = Verb 'PATCH 202
- type PatchNoContent = NoContentVerb 'PATCH
- type PatchNonAuthoritative = Verb 'PATCH 203
- type Post = Verb 'POST 200
- type PostAccepted = Verb 'POST 202
- type PostCreated = Verb 'POST 201
- type PostNoContent = NoContentVerb 'POST
- type PostNonAuthoritative = Verb 'POST 203
- type PostResetContent = Verb 'POST 205
- type Put = Verb 'PUT 200
- type PutAccepted = Verb 'PUT 202
- type PutCreated = Verb 'PUT 201
- type PutNoContent = NoContentVerb 'PUT
- type PutNonAuthoritative = Verb 'PUT 203
- class ReflectMethod (a :: k) where
- reflectMethod :: Proxy a -> Method
- data Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [Type]) a
- statusOf :: HasStatus a => proxy a -> Status
- class KnownStatus (StatusOf a) => HasStatus a where
- type family Statuses (as :: [Type]) :: [Nat]
- type family StatusOf a :: Nat
- type family Statuses (as :: [Type]) :: [Nat]
- data UVerb (method :: StdMethod) (contentTypes :: [Type]) (as :: [Type])
- newtype WithStatus (k :: Nat) a = WithStatus a
- type IsMember (a :: u) (as :: [u]) = (Unique as, CheckElemIsMember a as, UElem a as)
- inject :: UElem x xs => f x -> NS f xs
- type Union = NS I
- type family Unique (xs :: [k]) where ...
- module Servant.API.NamedRoutes
- fromServant :: forall {k} routes (mode :: k). GenericServant routes mode => ToServant routes mode -> routes mode
- genericApi :: forall (routes :: Type -> Type). GenericServant routes AsApi => Proxy routes -> Proxy (ToServantApi routes)
- toServant :: forall {k} routes (mode :: k). GenericServant routes mode => routes mode -> ToServant routes mode
- type family (mode :: k) :- api
- data AsApi
- class GServantProduct (f :: k -> Type)
- class GenericMode (mode :: k) where
- type (mode :: k) :- api
- type GenericServant (routes :: k -> Type) (mode :: k) = (GenericMode mode, Generic (routes mode), GServantProduct (Rep (routes mode)))
- type ToServant (routes :: k -> Type) (mode :: k) = GToServant (Rep (routes mode))
- type ToServantApi (routes :: Type -> Type) = ToServant routes AsApi
- class FramingRender (strategy :: k) where
- framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy strategy -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString
- class FramingUnrender (strategy :: k) where
- framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy strategy -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a
- class FromSourceIO chunk a | a -> chunk where
- fromSourceIO :: SourceIO chunk -> IO a
- data NetstringFraming
- data NewlineFraming
- data NoFraming
- type SourceIO = SourceT IO
- data Stream (method :: k1) (status :: Nat) framing contentType a
- type StreamBody = StreamBody' ('[] :: [Type])
- data StreamBody' (mods :: [Type]) framing contentType a
- type StreamGet = Stream 'GET 200
- type StreamPost = Stream 'POST 200
- class ToSourceIO chunk a | a -> chunk where
- toSourceIO :: a -> SourceIO chunk
- module Servant.API.BasicAuth
- data Description (sym :: Symbol)
- data Summary (sym :: Symbol)
- class Accept (ctype :: k) where
- contentType :: Proxy ctype -> MediaType
- contentTypes :: Proxy ctype -> NonEmpty MediaType
- data FormUrlEncoded
- data JSON
- class Accept ctype => MimeRender (ctype :: k) a where
- mimeRender :: Proxy ctype -> a -> ByteString
- class Accept ctype => MimeUnrender (ctype :: k) a where
- mimeUnrender :: Proxy ctype -> ByteString -> Either String a
- mimeUnrenderWithType :: Proxy ctype -> MediaType -> ByteString -> Either String a
- data NoContent = NoContent
- data OctetStream
- data PlainText
- addHeader :: forall (h :: Symbol) v orig new. AddHeader '[Optional, Strict] h v orig new => v -> orig -> new
- addHeader' :: forall (mods :: [Type]) (h :: Symbol) v orig new. AddHeader mods h v orig new => v -> orig -> new
- lookupResponseHeader :: forall (h :: Symbol) a (headers :: [Type]) r. HasResponseHeader h a headers => Headers headers r -> ResponseHeader h a
- noHeader :: forall (h :: Symbol) v orig new. AddHeader '[Optional, Strict] h v orig new => orig -> new
- noHeader' :: forall (mods :: [Type]) (h :: Symbol) v orig new. AddHeader mods h v orig new => orig -> new
- class AddHeader (mods :: [Type]) (h :: Symbol) v orig new | mods h v orig -> new, new -> mods, new -> h, new -> v, new -> orig
- class BuildHeadersTo (hs :: [Type]) where
- buildHeadersTo :: [Header] -> HList hs
- class GetHeaders ls where
- getHeaders :: ls -> [Header]
- data HList (a :: [Type]) where
- class HasResponseHeader (h :: Symbol) a (headers :: [Type])
- data Headers (ls :: [Type]) a = Headers {
- getResponse :: a
- getHeadersHList :: HList ls
- data ResponseHeader (sym :: Symbol) a
- module Servant.API.Raw
- class FromHttpApiData a where
- parseUrlPiece :: Text -> Either Text a
- parseHeader :: ByteString -> Either Text a
- parseQueryParam :: Text -> Either Text a
- class ToHttpApiData a where
- toUrlPiece :: a -> Text
- toEncodedUrlPiece :: a -> Builder
- toHeader :: a -> ByteString
- toQueryParam :: a -> Text
- toEncodedQueryParam :: a -> Builder
- module Servant.API.Experimental.Auth
- safeLink :: (IsElem endpoint api, HasLink endpoint) => Proxy api -> Proxy endpoint -> MkLink endpoint Link
- data URI = URI {}
- type family IsElem endpoint api where ...
- type family IsElem' a s
- class HasLink (endpoint :: k) where
- data Link
- type family MkLink (endpoint :: k) a
- type family If (cond :: Bool) (tru :: k) (fls :: k) :: k where ...
- data SBool (b :: Bool) where
- class SBoolI (b :: Bool) where
Combinators
module Servant.API.Sub
Type-level combinator for expressing subrouting: :>
module Servant.API.Alternative
Type-level combinator for alternative endpoints: :<|>
module Servant.API.Empty
Type-level combinator for an empty API: EmptyAPI
Type-level modifiers for QueryParam
, Header
and ReqBody
.
Accessing information from the request
module Servant.API.Capture
Capturing parts of the url path as parsed values:
and Capture
CaptureAll
module Servant.API.Header
Retrieving specific headers from the request
module Servant.API.HttpVersion
Retrieving the HTTP version of the request
module Servant.API.QueryParam
Retrieving parameters from the query string of the URI
: QueryParam
data DeepQuery (sym :: Symbol) a Source #
Extract an deep object from a query string.
Example:
>>>
-- /books?filter[author][name]=<author name>&filter[year]=<book year>
>>>
type MyApi = "books" :> DeepQuery "filter" BookQuery :> Get '[JSON] [Book]
data QueryString Source #
Extract the whole query string from a request. This is useful for query strings
containing dynamic parameter names. For query strings with static parameter names,
QueryParam
is more suited.
Example:
>>>
-- /books?author=<author name>&year=<book year>
>>>
type MyApi = "books" :> QueryString :> Get '[JSON] [Book]
Retrieving the complete query string of the URI
: QueryString
module Servant.API.Fragment
module Servant.API.ReqBody
Accessing the request body as a JSON-encoded type: ReqBody
module Servant.API.RemoteHost
Retrieving the IP of the client
module Servant.API.IsSecure
Is the request made through HTTPS?
module Servant.API.Vault
Access the location for arbitrary data to be shared by applications and middleware
module Servant.API.WithNamedContext
Access context entries in combinators in servant-server
module Servant.API.WithResource
Access a managed resource scoped to a single request
Actual endpoints, distinguished by HTTP method
HTTP standard method (as defined by RFC 2616, and PATCH which is defined by RFC 5789).
Since: http-types-0.2.0
Instances
type DeleteNoContent = NoContentVerb 'DELETE Source #
DELETE
with 204 status code.
type GetNoContent = NoContentVerb 'GET Source #
GET
with 204 status code.
data NoContentVerb (method :: k1) Source #
NoContentVerb
is a specific type to represent NoContent
responses.
It does not require either a list of content types (because there's
no content) or a status code (because it should always be 204).
Instances
HasLink (NoContentVerb m :: Type) Source # | |||||
Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (NoContentVerb m) -> Link -> MkLink (NoContentVerb m) a Source # | |||||
Generic (NoContentVerb method) Source # | |||||
Defined in Servant.API.Verbs Associated Types
Methods from :: NoContentVerb method -> Rep (NoContentVerb method) x # to :: Rep (NoContentVerb method) x -> NoContentVerb method # | |||||
type MkLink (NoContentVerb m :: Type) r Source # | |||||
Defined in Servant.Links | |||||
type Rep (NoContentVerb method) Source # | |||||
Defined in Servant.API.Verbs |
type PatchNoContent = NoContentVerb 'PATCH Source #
PATCH
with 204 status code.
type PostNoContent = NoContentVerb 'POST Source #
POST
with 204 status code.
type PutNoContent = NoContentVerb 'PUT Source #
PUT
with 204 status code.
class ReflectMethod (a :: k) where Source #
Methods
reflectMethod :: Proxy a -> Method Source #
Instances
ReflectMethod 'CONNECT Source # | |
Defined in Servant.API.Verbs | |
ReflectMethod 'DELETE Source # | |
Defined in Servant.API.Verbs | |
ReflectMethod 'GET Source # | |
Defined in Servant.API.Verbs | |
ReflectMethod 'HEAD Source # | |
Defined in Servant.API.Verbs | |
ReflectMethod 'OPTIONS Source # | |
Defined in Servant.API.Verbs | |
ReflectMethod 'PATCH Source # | |
Defined in Servant.API.Verbs | |
ReflectMethod 'POST Source # | |
Defined in Servant.API.Verbs | |
ReflectMethod 'PUT Source # | |
Defined in Servant.API.Verbs | |
ReflectMethod 'TRACE Source # | |
Defined in Servant.API.Verbs |
data Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [Type]) a Source #
Verb
is a general type for representing HTTP verbs (a.k.a. methods). For
convenience, type synonyms for each verb with a 200 response code are
provided, but you are free to define your own:
>>>
type Post204 contentTypes a = Verb 'POST 204 contentTypes a
Instances
HasLink (Verb m s ct a :: Type) Source # | |
Generic (Verb method statusCode contentTypes a) Source # | |
Defined in Servant.API.Verbs | |
AtMostOneFragment (Verb m s ct typ) Source # | |
Defined in Servant.API.TypeLevel | |
type MkLink (Verb m s ct a :: Type) r Source # | |
Defined in Servant.Links | |
type Rep (Verb method statusCode contentTypes a) Source # | |
class KnownStatus (StatusOf a) => HasStatus a Source #
Instances
HasStatus NoContent Source # | If an API can respond with | ||||
Defined in Servant.API.UVerb Associated Types
| |||||
HasStatus a => HasStatus (Headers ls a) Source # | |||||
Defined in Servant.API.UVerb | |||||
KnownStatus n => HasStatus (WithStatus n a) Source # | an instance of this typeclass assigns a HTTP status code to a return type Example: data NotFoundError = NotFoundError String instance HasStatus NotFoundError where type StatusOf NotFoundError = 404 You can also use the convience newtype wrapper | ||||
Defined in Servant.API.UVerb Associated Types
|
type family StatusOf a :: Nat Source #
Instances
type StatusOf NoContent Source # | |
Defined in Servant.API.UVerb | |
type StatusOf (Headers ls a) Source # | |
Defined in Servant.API.UVerb | |
type StatusOf (WithStatus n a) Source # | |
Defined in Servant.API.UVerb |
data UVerb (method :: StdMethod) (contentTypes :: [Type]) (as :: [Type]) Source #
A variant of Verb
that can have any of a number of response values and status codes.
FUTUREWORK: it would be nice to make Verb
a special case of UVerb
, and only write
instances for HasServer
etc. for the latter, getting them for the former for free.
Something like:
type Verb method statusCode contentTypes a = UVerb method contentTypes [WithStatus statusCode a]
Backwards compatibility is tricky, though: this type alias would mean people would have to
use respond
instead of pure
or return
, so all old handlers would have to be rewritten.
newtype WithStatus (k :: Nat) a Source #
A simple newtype wrapper that pairs a type with its status code. It implements all the content types that Servant ships with by default.
Constructors
WithStatus a |
Instances
MimeRender FormUrlEncoded a => MimeRender FormUrlEncoded (WithStatus _status a) Source # | |||||
Defined in Servant.API.UVerb Methods mimeRender :: Proxy FormUrlEncoded -> WithStatus _status a -> ByteString Source # | |||||
MimeRender JSON a => MimeRender JSON (WithStatus _status a) Source # | |||||
Defined in Servant.API.UVerb Methods mimeRender :: Proxy JSON -> WithStatus _status a -> ByteString Source # | |||||
MimeRender OctetStream a => MimeRender OctetStream (WithStatus _status a) Source # | |||||
Defined in Servant.API.UVerb Methods mimeRender :: Proxy OctetStream -> WithStatus _status a -> ByteString Source # | |||||
MimeRender PlainText a => MimeRender PlainText (WithStatus _status a) Source # | |||||
Defined in Servant.API.UVerb Methods mimeRender :: Proxy PlainText -> WithStatus _status a -> ByteString Source # | |||||
MimeUnrender FormUrlEncoded a => MimeUnrender FormUrlEncoded (WithStatus _status a) Source # | |||||
Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy FormUrlEncoded -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy FormUrlEncoded -> MediaType -> ByteString -> Either String (WithStatus _status a) Source # | |||||
MimeUnrender JSON a => MimeUnrender JSON (WithStatus _status a) Source # | |||||
Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy JSON -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy JSON -> MediaType -> ByteString -> Either String (WithStatus _status a) Source # | |||||
MimeUnrender OctetStream a => MimeUnrender OctetStream (WithStatus _status a) Source # | |||||
Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String (WithStatus _status a) Source # | |||||
MimeUnrender PlainText a => MimeUnrender PlainText (WithStatus _status a) Source # | |||||
Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String (WithStatus _status a) Source # | |||||
Show a => Show (WithStatus k a) Source # | |||||
Defined in Servant.API.UVerb Methods showsPrec :: Int -> WithStatus k a -> ShowS # show :: WithStatus k a -> String # showList :: [WithStatus k a] -> ShowS # | |||||
Eq a => Eq (WithStatus k a) Source # | |||||
Defined in Servant.API.UVerb Methods (==) :: WithStatus k a -> WithStatus k a -> Bool # (/=) :: WithStatus k a -> WithStatus k a -> Bool # | |||||
KnownStatus n => HasStatus (WithStatus n a) Source # | an instance of this typeclass assigns a HTTP status code to a return type Example: data NotFoundError = NotFoundError String instance HasStatus NotFoundError where type StatusOf NotFoundError = 404 You can also use the convience newtype wrapper | ||||
Defined in Servant.API.UVerb Associated Types
| |||||
type StatusOf (WithStatus n a) Source # | |||||
Defined in Servant.API.UVerb |
type family Unique (xs :: [k]) where ... Source #
Check whether all values in a type-level list are distinct. This will throw a nice error if there are any duplicate elements in the list.
Sub-APIs defined as records of routes
module Servant.API.NamedRoutes
fromServant :: forall {k} routes (mode :: k). GenericServant routes mode => ToServant routes mode -> routes mode Source #
Inverse of toServant
.
This can be used to turn generated
values such as client functions into records.
You may need to provide a type signature for the output type (your record type).
genericApi :: forall (routes :: Type -> Type). GenericServant routes AsApi => Proxy routes -> Proxy (ToServantApi routes) Source #
Get a Proxy
of an API type.
toServant :: forall {k} routes (mode :: k). GenericServant routes mode => routes mode -> ToServant routes mode Source #
See ToServant
, but at value-level.
A type that specifies that an API record contains an API definition. Only useful at type-level.
Instances
GenericMode AsApi Source # | |||||
Defined in Servant.API.Generic Associated Types
| |||||
type AsApi :- api Source # | |||||
Defined in Servant.API.Generic |
class GServantProduct (f :: k -> Type) Source #
Minimal complete definition
gtoServant, gfromServant
Instances
(GServantProduct l, GServantProduct r) => GServantProduct (l :*: r :: k -> Type) Source # | |
Defined in Servant.API.Generic Methods gtoServant :: forall (p :: k). (l :*: r) p -> GToServant (l :*: r) gfromServant :: forall (p :: k). GToServant (l :*: r) -> (l :*: r) p | |
GServantProduct (K1 i c :: k -> Type) Source # | |
Defined in Servant.API.Generic Methods gtoServant :: forall (p :: k). K1 i c p -> GToServant (K1 i c :: k -> Type) gfromServant :: forall (p :: k). GToServant (K1 i c :: k -> Type) -> K1 i c p | |
GServantProduct f => GServantProduct (M1 i c f :: k -> Type) Source # | |
Defined in Servant.API.Generic Methods gtoServant :: forall (p :: k). M1 i c f p -> GToServant (M1 i c f) gfromServant :: forall (p :: k). GToServant (M1 i c f) -> M1 i c f p |
class GenericMode (mode :: k) Source #
A class with a type family that applies an appropriate type family to the api
parameter. For example, AsApi
will leave api
untouched, while
will produce AsServerT
m
.ServerT
api m
Instances
GenericMode AsApi Source # | |||||
Defined in Servant.API.Generic Associated Types
| |||||
GenericMode (AsLink a :: Type) Source # | |||||
Defined in Servant.Links |
type GenericServant (routes :: k -> Type) (mode :: k) = (GenericMode mode, Generic (routes mode), GServantProduct (Rep (routes mode))) Source #
A constraint alias, for work with mode
and routes
.
type ToServant (routes :: k -> Type) (mode :: k) = GToServant (Rep (routes mode)) Source #
Turns a generic product type into a tree of :<|>
combinators.
Streaming endpoints, distinguished by HTTP method
class FramingRender (strategy :: k) where Source #
The FramingRender
class provides the logic for emitting a framing strategy.
The strategy transforms a
into SourceT
m a
,
therefore it can prepend, append and intercalate framing structure
around chunks.SourceT
m ByteString
Note: as the
is generic, this is pure transformation.Monad
m
Methods
framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy strategy -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source #
Instances
FramingRender NetstringFraming Source # | |
Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NetstringFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source # | |
FramingRender NewlineFraming Source # | |
Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NewlineFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source # | |
FramingRender NoFraming Source # | |
Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NoFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source # |
class FramingUnrender (strategy :: k) where Source #
The FramingUnrender
class provides the logic for parsing a framing
strategy.
Methods
framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy strategy -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source #
Instances
FramingUnrender NetstringFraming Source # | |
Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NetstringFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source # | |
FramingUnrender NewlineFraming Source # | |
Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NewlineFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source # | |
FramingUnrender NoFraming Source # | As That works well when |
Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NoFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source # |
class FromSourceIO chunk a | a -> chunk where Source #
FromSourceIO
is intended to be implemented for types such as Conduit,
Pipe, etc. By implementing this class, all such streaming abstractions can
be used directly on the client side for talking to streaming endpoints.
Methods
fromSourceIO :: SourceIO chunk -> IO a Source #
Instances
MonadIO m => FromSourceIO a (SourceT m a) Source # | |
Defined in Servant.API.Stream |
data NetstringFraming Source #
The netstring framing strategy as defined by djb: http://cr.yp.to/proto/netstrings.txt
Any string of 8-bit bytes may be encoded as [len]":"[string]","
. Here
[string]
is the string and [len]
is a nonempty sequence of ASCII digits
giving the length of [string]
in decimal. The ASCII digits are 30
for
0, 31
for 1, and so on up through 39
for 9. Extra zeros at the front
of [len]
are prohibited: [len]
begins with 30
exactly when
[string]
is empty.
For example, the string "hello world!"
is encoded as
32 3a 68 65 6c 6c 6f 20 77 6f 72 6c 64 21 2c
,
i.e., "12:hello world!,"
.
The empty string is encoded as "0:,"
.
Instances
FramingRender NetstringFraming Source # | |
Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NetstringFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source # | |
FramingUnrender NetstringFraming Source # | |
Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NetstringFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source # |
data NewlineFraming Source #
A simple framing strategy that has no header, and inserts a newline character after each frame. This assumes that it is used with a Content-Type that encodes without newlines (e.g. JSON).
Instances
FramingRender NewlineFraming Source # | |
Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NewlineFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source # | |
FramingUnrender NewlineFraming Source # | |
Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NewlineFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source # |
A framing strategy that does not do any framing at all, it just passes the input data This will be used most of the time with binary data, such as files
Instances
FramingRender NoFraming Source # | |
Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NoFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source # | |
FramingUnrender NoFraming Source # | As That works well when |
Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NoFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source # |
data Stream (method :: k1) (status :: Nat) framing contentType a Source #
A Stream endpoint for a given method emits a stream of encoded values at a
given Content-Type
, delimited by a framing
strategy.
Type synonyms are provided for standard methods.
Instances
HasLink (Stream m status fr ct a :: Type) Source # | |
Generic (Stream method status framing contentType a) Source # | |
Defined in Servant.API.Stream | |
type MkLink (Stream m status fr ct a :: Type) r Source # | |
Defined in Servant.Links | |
type Rep (Stream method status framing contentType a) Source # | |
type StreamBody = StreamBody' ('[] :: [Type]) Source #
A stream request body.
data StreamBody' (mods :: [Type]) framing contentType a Source #
Instances
HasLink sub => HasLink (StreamBody' mods framing ct a :> sub :: Type) Source # | |||||
Defined in Servant.Links | |||||
Generic (StreamBody' mods framing contentType a) Source # | |||||
Defined in Servant.API.Stream Associated Types
Methods from :: StreamBody' mods framing contentType a -> Rep (StreamBody' mods framing contentType a) x # to :: Rep (StreamBody' mods framing contentType a) x -> StreamBody' mods framing contentType a # | |||||
type MkLink (StreamBody' mods framing ct a :> sub :: Type) r Source # | |||||
Defined in Servant.Links | |||||
type Rep (StreamBody' mods framing contentType a) Source # | |||||
Defined in Servant.API.Stream |
type StreamPost = Stream 'POST 200 Source #
class ToSourceIO chunk a | a -> chunk where Source #
ToSourceIO
is intended to be implemented for types such as Conduit, Pipe,
etc. By implementing this class, all such streaming abstractions can be used
directly as endpoints.
Methods
toSourceIO :: a -> SourceIO chunk Source #
Instances
ToSourceIO a (NonEmpty a) Source # | |
Defined in Servant.API.Stream Methods toSourceIO :: NonEmpty a -> SourceIO a Source # | |
ToSourceIO a [a] Source # | |
Defined in Servant.API.Stream Methods toSourceIO :: [a] -> SourceIO a Source # | |
SourceToSourceIO m => ToSourceIO chunk (SourceT m chunk) Source # | Relax to use auxiliary class, have m |
Defined in Servant.API.Stream Methods toSourceIO :: SourceT m chunk -> SourceIO chunk Source # |
Authentication
module Servant.API.BasicAuth
Endpoints description
data Description (sym :: Symbol) Source #
Add more verbose description for (part of) API.
Example:
>>>
:{
type MyApi = Description "This comment is visible in multiple Servant interpretations \ \and can be really long if necessary. \ \Haskell multiline String support is not perfect \ \but it's still very readable." :> Get '[JSON] Book :}
Instances
HasLink sub => HasLink (Description s :> sub :: Type) Source # | |
Defined in Servant.Links | |
type MkLink (Description s :> sub :: Type) a Source # | |
Defined in Servant.Links |
data Summary (sym :: Symbol) Source #
Add a short summary for (part of) API.
Example:
>>>
type MyApi = Summary "Get book by ISBN." :> "books" :> Capture "isbn" Text :> Get '[JSON] Book
Content Types
class Accept (ctype :: k) where Source #
Instances of Accept
represent mimetypes. They are used for matching
against the Accept
HTTP header of the request, and for setting the
Content-Type
header of the response
Example:
>>>
import Network.HTTP.Media ((//), (/:))
>>>
data HTML
>>>
:{
instance Accept HTML where contentType _ = "text" // "html" /: ("charset", "utf-8") :}
Minimal complete definition
Methods
contentType :: Proxy ctype -> MediaType Source #
Instances
Accept FormUrlEncoded Source # | application/x-www-form-urlencoded |
Defined in Servant.API.ContentTypes Methods contentType :: Proxy FormUrlEncoded -> MediaType Source # contentTypes :: Proxy FormUrlEncoded -> NonEmpty MediaType Source # | |
Accept JSON Source # | application/json |
Defined in Servant.API.ContentTypes | |
Accept OctetStream Source # | application/octet-stream |
Defined in Servant.API.ContentTypes Methods contentType :: Proxy OctetStream -> MediaType Source # contentTypes :: Proxy OctetStream -> NonEmpty MediaType Source # | |
Accept PlainText Source # | text/plain;charset=utf-8 |
Defined in Servant.API.ContentTypes |
data FormUrlEncoded Source #
Instances
Accept FormUrlEncoded Source # | application/x-www-form-urlencoded |
Defined in Servant.API.ContentTypes Methods contentType :: Proxy FormUrlEncoded -> MediaType Source # contentTypes :: Proxy FormUrlEncoded -> NonEmpty MediaType Source # | |
ToForm a => MimeRender FormUrlEncoded a Source # |
|
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy FormUrlEncoded -> a -> ByteString Source # | |
FromForm a => MimeUnrender FormUrlEncoded a Source # |
|
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy FormUrlEncoded -> ByteString -> Either String a Source # mimeUnrenderWithType :: Proxy FormUrlEncoded -> MediaType -> ByteString -> Either String a Source # | |
MimeRender FormUrlEncoded a => MimeRender FormUrlEncoded (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeRender :: Proxy FormUrlEncoded -> WithStatus _status a -> ByteString Source # | |
MimeUnrender FormUrlEncoded a => MimeUnrender FormUrlEncoded (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy FormUrlEncoded -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy FormUrlEncoded -> MediaType -> ByteString -> Either String (WithStatus _status a) Source # |
Instances
Accept JSON Source # | application/json |
Defined in Servant.API.ContentTypes | |
ToJSON a => MimeRender JSON a Source # | |
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy JSON -> a -> ByteString Source # | |
FromJSON a => MimeUnrender JSON a Source # | |
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy JSON -> ByteString -> Either String a Source # mimeUnrenderWithType :: Proxy JSON -> MediaType -> ByteString -> Either String a Source # | |
MimeRender JSON a => MimeRender JSON (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeRender :: Proxy JSON -> WithStatus _status a -> ByteString Source # | |
MimeUnrender JSON a => MimeUnrender JSON (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy JSON -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy JSON -> MediaType -> ByteString -> Either String (WithStatus _status a) Source # |
class Accept ctype => MimeRender (ctype :: k) a where Source #
Instantiate this class to register a way of serializing a type based
on the Accept
header.
Example:
data MyContentType instance Accept MyContentType where contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8") instance Show a => MimeRender MyContentType a where mimeRender _ val = pack ("This is MINE! " ++ show val) type MyAPI = "path" :> Get '[MyContentType] Int
Methods
mimeRender :: Proxy ctype -> a -> ByteString Source #
Instances
ToForm a => MimeRender FormUrlEncoded a Source # |
|
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy FormUrlEncoded -> a -> ByteString Source # | |
ToJSON a => MimeRender JSON a Source # | |
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy JSON -> a -> ByteString Source # | |
MimeRender OctetStream ByteString Source # | |
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy OctetStream -> ByteString -> ByteString Source # | |
MimeRender OctetStream ByteString Source # | id |
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy OctetStream -> ByteString -> ByteString Source # | |
MimeRender PlainText Text Source # | fromStrict . TextS.encodeUtf8 |
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy PlainText -> Text -> ByteString Source # | |
MimeRender PlainText Text Source # | |
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy PlainText -> Text -> ByteString Source # | |
MimeRender PlainText String Source # | BC.pack |
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy PlainText -> String -> ByteString Source # | |
MimeRender FormUrlEncoded a => MimeRender FormUrlEncoded (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeRender :: Proxy FormUrlEncoded -> WithStatus _status a -> ByteString Source # | |
MimeRender JSON a => MimeRender JSON (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeRender :: Proxy JSON -> WithStatus _status a -> ByteString Source # | |
MimeRender OctetStream a => MimeRender OctetStream (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeRender :: Proxy OctetStream -> WithStatus _status a -> ByteString Source # | |
MimeRender PlainText a => MimeRender PlainText (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeRender :: Proxy PlainText -> WithStatus _status a -> ByteString Source # |
class Accept ctype => MimeUnrender (ctype :: k) a where Source #
Instantiate this class to register a way of deserializing a type based
on the request's Content-Type
header.
>>>
import Network.HTTP.Media hiding (Accept)
>>>
import qualified Data.ByteString.Lazy.Char8 as BSC
>>>
data MyContentType = MyContentType String
>>>
:{
instance Accept MyContentType where contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8") :}
>>>
:{
instance Read a => MimeUnrender MyContentType a where mimeUnrender _ bs = case BSC.take 12 bs of "MyContentType" -> return . read . BSC.unpack $ BSC.drop 12 bs _ -> Left "didn't start with the magic incantation" :}
>>>
type MyAPI = "path" :> ReqBody '[MyContentType] Int :> Get '[JSON] Int
Minimal complete definition
Methods
mimeUnrender :: Proxy ctype -> ByteString -> Either String a Source #
mimeUnrenderWithType :: Proxy ctype -> MediaType -> ByteString -> Either String a Source #
Instances
FromForm a => MimeUnrender FormUrlEncoded a Source # |
|
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy FormUrlEncoded -> ByteString -> Either String a Source # mimeUnrenderWithType :: Proxy FormUrlEncoded -> MediaType -> ByteString -> Either String a Source # | |
FromJSON a => MimeUnrender JSON a Source # | |
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy JSON -> ByteString -> Either String a Source # mimeUnrenderWithType :: Proxy JSON -> MediaType -> ByteString -> Either String a Source # | |
MimeUnrender OctetStream ByteString Source # | Right . toStrict |
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String ByteString Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String ByteString Source # | |
MimeUnrender OctetStream ByteString Source # | Right . id |
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String ByteString Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String ByteString Source # | |
MimeUnrender PlainText Text Source # | left show . TextS.decodeUtf8' . toStrict |
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String Text Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String Text Source # | |
MimeUnrender PlainText Text Source # | left show . TextL.decodeUtf8' |
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String Text Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String Text Source # | |
MimeUnrender PlainText String Source # | Right . BC.unpack |
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String String Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String String Source # | |
MimeUnrender FormUrlEncoded a => MimeUnrender FormUrlEncoded (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy FormUrlEncoded -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy FormUrlEncoded -> MediaType -> ByteString -> Either String (WithStatus _status a) Source # | |
MimeUnrender JSON a => MimeUnrender JSON (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy JSON -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy JSON -> MediaType -> ByteString -> Either String (WithStatus _status a) Source # | |
MimeUnrender OctetStream a => MimeUnrender OctetStream (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String (WithStatus _status a) Source # | |
MimeUnrender PlainText a => MimeUnrender PlainText (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String (WithStatus _status a) Source # |
A type for responses without content-body.
Constructors
NoContent |
Instances
NFData NoContent Source # | |||||
Defined in Servant.API.ContentTypes | |||||
Generic NoContent Source # | |||||
Defined in Servant.API.ContentTypes | |||||
Read NoContent Source # | |||||
Show NoContent Source # | |||||
Eq NoContent Source # | |||||
HasStatus NoContent Source # | If an API can respond with | ||||
Defined in Servant.API.UVerb Associated Types
| |||||
AllMime (ctyp ': (ctyp' ': ctyps)) => AllMimeRender (ctyp ': (ctyp' ': ctyps)) NoContent Source # | |||||
Defined in Servant.API.ContentTypes Methods allMimeRender :: Proxy (ctyp ': (ctyp' ': ctyps)) -> NoContent -> [(MediaType, ByteString)] Source # | |||||
Accept ctyp => AllMimeRender '[ctyp] NoContent Source # | |||||
Defined in Servant.API.ContentTypes Methods allMimeRender :: Proxy '[ctyp] -> NoContent -> [(MediaType, ByteString)] Source # | |||||
type Rep NoContent Source # | |||||
type StatusOf NoContent Source # | |||||
Defined in Servant.API.UVerb |
data OctetStream Source #
Instances
Accept OctetStream Source # | application/octet-stream |
Defined in Servant.API.ContentTypes Methods contentType :: Proxy OctetStream -> MediaType Source # contentTypes :: Proxy OctetStream -> NonEmpty MediaType Source # | |
MimeRender OctetStream ByteString Source # | |
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy OctetStream -> ByteString -> ByteString Source # | |
MimeRender OctetStream ByteString Source # | id |
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy OctetStream -> ByteString -> ByteString Source # | |
MimeUnrender OctetStream ByteString Source # | Right . toStrict |
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String ByteString Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String ByteString Source # | |
MimeUnrender OctetStream ByteString Source # | Right . id |
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String ByteString Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String ByteString Source # | |
MimeRender OctetStream a => MimeRender OctetStream (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeRender :: Proxy OctetStream -> WithStatus _status a -> ByteString Source # | |
MimeUnrender OctetStream a => MimeUnrender OctetStream (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String (WithStatus _status a) Source # |
Instances
Accept PlainText Source # | text/plain;charset=utf-8 |
Defined in Servant.API.ContentTypes | |
MimeRender PlainText Text Source # | fromStrict . TextS.encodeUtf8 |
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy PlainText -> Text -> ByteString Source # | |
MimeRender PlainText Text Source # | |
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy PlainText -> Text -> ByteString Source # | |
MimeRender PlainText String Source # | BC.pack |
Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy PlainText -> String -> ByteString Source # | |
MimeUnrender PlainText Text Source # | left show . TextS.decodeUtf8' . toStrict |
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String Text Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String Text Source # | |
MimeUnrender PlainText Text Source # | left show . TextL.decodeUtf8' |
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String Text Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String Text Source # | |
MimeUnrender PlainText String Source # | Right . BC.unpack |
Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String String Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String String Source # | |
MimeRender PlainText a => MimeRender PlainText (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeRender :: Proxy PlainText -> WithStatus _status a -> ByteString Source # | |
MimeUnrender PlainText a => MimeUnrender PlainText (WithStatus _status a) Source # | |
Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String (WithStatus _status a) Source # |
Serializing and deserializing types based on Accept
and
Content-Type
headers.
Response Headers
addHeader :: forall (h :: Symbol) v orig new. AddHeader '[Optional, Strict] h v orig new => v -> orig -> new Source #
addHeader
adds a header to a response. Note that it changes the type of
the value in the following ways:
- A simple value is wrapped in "Headers '[hdr]":
>>>
let example0 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
>>>
getHeaders example0
[("someheader","5")]
- A value that already has a header has its new header *prepended* to the existing list:
>>>
let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
>>>
let example2 = addHeader True example1 :: Headers '[Header "1st" Bool, Header "someheader" Int] String
>>>
getHeaders example2
[("1st","true"),("someheader","5")]
Note that while in your handlers type annotations are not required, since the type can be inferred from the API type, in other cases you may find yourself needing to add annotations.
addHeader' :: forall (mods :: [Type]) (h :: Symbol) v orig new. AddHeader mods h v orig new => v -> orig -> new Source #
lookupResponseHeader :: forall (h :: Symbol) a (headers :: [Type]) r. HasResponseHeader h a headers => Headers headers r -> ResponseHeader h a Source #
Look up a specific ResponseHeader, without having to know what position it is in the HList.
>>>
let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String
>>>
let example2 = addHeader True example1 :: Headers '[Header "1st" Bool, Header "someheader" Int] String
>>>
lookupResponseHeader example2 :: ResponseHeader "someheader" Int
Header 5
>>>
lookupResponseHeader example2 :: ResponseHeader "1st" Bool
Header True
Usage of this function relies on an explicit type annotation of the header to be looked up. This can be done with type annotations on the result, or with an explicit type application. In this example, the type of header value is determined by the type-inference, we only specify the name of the header:
>>>
:set -XTypeApplications
>>>
case lookupResponseHeader @"1st" example2 of { Header b -> b ; _ -> False }
True
Since: 0.15
noHeader :: forall (h :: Symbol) v orig new. AddHeader '[Optional, Strict] h v orig new => orig -> new Source #
Deliberately do not add a header to a value.
>>>
let example1 = noHeader "hi" :: Headers '[Header "someheader" Int] String
>>>
getHeaders example1
[]
noHeader' :: forall (mods :: [Type]) (h :: Symbol) v orig new. AddHeader mods h v orig new => orig -> new Source #
class AddHeader (mods :: [Type]) (h :: Symbol) v orig new | mods h v orig -> new, new -> mods, new -> h, new -> v, new -> orig Source #
Minimal complete definition
addOptionalHeader
Instances
(KnownSymbol h, ToHttpApiData v, new ~ Headers '[Header' mods h v] a) => AddHeader mods h v a new Source # | |
Defined in Servant.API.ResponseHeaders Methods addOptionalHeader :: ResponseHeader h v -> a -> new | |
(AddHeader mods h v old new, AddHeader mods h v (Union oldrest) (Union newrest), oldrest ~ (a ': as), newrest ~ (b ': bs)) => AddHeader mods h v (Union (old ': (a ': as))) (Union (new ': (b ': bs))) Source # | |
Defined in Servant.API.ResponseHeaders Methods addOptionalHeader :: ResponseHeader h v -> Union (old ': (a ': as)) -> Union (new ': (b ': bs)) | |
AddHeader mods h v old new => AddHeader mods h v (Union '[old]) (Union '[new]) Source # | |
Defined in Servant.API.ResponseHeaders Methods addOptionalHeader :: ResponseHeader h v -> Union '[old] -> Union '[new] | |
(KnownSymbol h, ToHttpApiData v) => AddHeader mods h v (Headers (fst ': rest) a) (Headers (Header' mods h v ': (fst ': rest)) a) Source # | |
Defined in Servant.API.ResponseHeaders Methods addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header' mods h v ': (fst ': rest)) a |
class BuildHeadersTo (hs :: [Type]) where Source #
Methods
buildHeadersTo :: [Header] -> HList hs Source #
Instances
BuildHeadersTo ('[] :: [Type]) Source # | |
Defined in Servant.API.ResponseHeaders | |
(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo (Header' mods h v ': xs) Source # | |
Defined in Servant.API.ResponseHeaders |
class GetHeaders ls where Source #
Methods
getHeaders :: ls -> [Header] Source #
Instances
GetHeadersFromHList hs => GetHeaders (HList hs) Source # | |
Defined in Servant.API.ResponseHeaders Methods getHeaders :: HList hs -> [Header] Source # | |
GetHeaders' hs => GetHeaders (Headers hs a) Source # | |
Defined in Servant.API.ResponseHeaders Methods getHeaders :: Headers hs a -> [Header] Source # |
data HList (a :: [Type]) where Source #
Constructors
HNil :: HList ('[] :: [Type]) | |
HCons :: forall (h :: Symbol) x (xs :: [Type]) (mods :: [Type]). ResponseHeader h x -> HList xs -> HList (Header' mods h x ': xs) |
Instances
NFDataHList xs => NFData (HList xs) Source # | |
Defined in Servant.API.ResponseHeaders | |
GetHeadersFromHList hs => GetHeaders (HList hs) Source # | |
Defined in Servant.API.ResponseHeaders Methods getHeaders :: HList hs -> [Header] Source # |
class HasResponseHeader (h :: Symbol) a (headers :: [Type]) Source #
Minimal complete definition
hlistLookupHeader
Instances
HasResponseHeader h a (Header' mods h a ': rest) Source # | |
Defined in Servant.API.ResponseHeaders Methods hlistLookupHeader :: HList (Header' mods h a ': rest) -> ResponseHeader h a | |
HasResponseHeader h a rest => HasResponseHeader h a (first ': rest) Source # | |
Defined in Servant.API.ResponseHeaders Methods hlistLookupHeader :: HList (first ': rest) -> ResponseHeader h a |
data Headers (ls :: [Type]) a Source #
Response Header objects. You should never need to construct one directly.
Instead, use addOptionalHeader
.
Constructors
Headers | |
Fields
|
Instances
(KnownSymbol h, ToHttpApiData v) => AddHeader mods h v (Headers (fst ': rest) a) (Headers (Header' mods h v ': (fst ': rest)) a) Source # | |
Defined in Servant.API.ResponseHeaders Methods addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header' mods h v ': (fst ': rest)) a | |
Functor (Headers ls) Source # | |
(NFDataHList ls, NFData a) => NFData (Headers ls a) Source # | |
Defined in Servant.API.ResponseHeaders | |
GetHeaders' hs => GetHeaders (Headers hs a) Source # | |
Defined in Servant.API.ResponseHeaders Methods getHeaders :: Headers hs a -> [Header] Source # | |
HasStatus a => HasStatus (Headers ls a) Source # | |
Defined in Servant.API.UVerb | |
type StatusOf (Headers ls a) Source # | |
Defined in Servant.API.UVerb |
data ResponseHeader (sym :: Symbol) a Source #
Constructors
Header a | |
MissingHeader | |
UndecodableHeader ByteString |
Instances
Functor (ResponseHeader sym) Source # | |
Defined in Servant.API.ResponseHeaders Methods fmap :: (a -> b) -> ResponseHeader sym a -> ResponseHeader sym b # (<$) :: a -> ResponseHeader sym b -> ResponseHeader sym a # | |
NFData a => NFData (ResponseHeader sym a) Source # | |
Defined in Servant.API.ResponseHeaders Methods rnf :: ResponseHeader sym a -> () # | |
Show a => Show (ResponseHeader sym a) Source # | |
Defined in Servant.API.ResponseHeaders Methods showsPrec :: Int -> ResponseHeader sym a -> ShowS # show :: ResponseHeader sym a -> String # showList :: [ResponseHeader sym a] -> ShowS # | |
Eq a => Eq (ResponseHeader sym a) Source # | |
Defined in Servant.API.ResponseHeaders Methods (==) :: ResponseHeader sym a -> ResponseHeader sym a -> Bool # (/=) :: ResponseHeader sym a -> ResponseHeader sym a -> Bool # |
Untyped endpoints
module Servant.API.Raw
Plugging in a wai Application
, serving directories
FromHttpApiData and ToHttpApiData
class FromHttpApiData a where Source #
Parse value from HTTP API data.
WARNING: Do not derive this using DeriveAnyClass
as the generated
instance will loop indefinitely.
Minimal complete definition
Methods
parseUrlPiece :: Text -> Either Text a Source #
Parse URL path piece.
parseHeader :: ByteString -> Either Text a Source #
Parse HTTP header value.
parseQueryParam :: Text -> Either Text a Source #
Parse query param value.
Instances
FromHttpApiData SetCookie Source # | Note: this instance works correctly for alphanumeric name and value
|
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Void Source # | Parsing a |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData All Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Any Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Version Source # |
|
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Int16 Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Int32 Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Int64 Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Int8 Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Word16 Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Word32 Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Word64 Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Word8 Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Ordering Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Text Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Text Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Day Source # |
|
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Month Source # |
|
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Quarter Source # |
|
Defined in Web.Internal.HttpApiData | |
FromHttpApiData QuarterOfYear Source # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text QuarterOfYear Source # parseHeader :: ByteString -> Either Text QuarterOfYear Source # parseQueryParam :: Text -> Either Text QuarterOfYear Source # | |
FromHttpApiData DayOfWeek Source # |
|
Defined in Web.Internal.HttpApiData | |
FromHttpApiData NominalDiffTime Source # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text NominalDiffTime Source # parseHeader :: ByteString -> Either Text NominalDiffTime Source # parseQueryParam :: Text -> Either Text NominalDiffTime Source # | |
FromHttpApiData UTCTime Source # |
|
Defined in Web.Internal.HttpApiData | |
FromHttpApiData LocalTime Source # |
|
Defined in Web.Internal.HttpApiData | |
FromHttpApiData TimeOfDay Source # |
|
Defined in Web.Internal.HttpApiData | |
FromHttpApiData ZonedTime Source # |
|
Defined in Web.Internal.HttpApiData | |
FromHttpApiData UUID Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Integer Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Natural Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData String Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData () Source # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text () Source # parseHeader :: ByteString -> Either Text () Source # | |
FromHttpApiData Bool Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Char Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Double Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Float Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Int Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData Word Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (First a) Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (Last a) Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (Max a) Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (Min a) Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (Identity a) Source # | Since: http-api-data-0.4.2 |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (First a) Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (Last a) Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (Dual a) Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (Product a) Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (Sum a) Source # | |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (LenientData a) Source # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (LenientData a) Source # parseHeader :: ByteString -> Either Text (LenientData a) Source # parseQueryParam :: Text -> Either Text (LenientData a) Source # | |
FromHttpApiData a => FromHttpApiData (Maybe a) Source # |
|
Defined in Web.Internal.HttpApiData | |
HasResolution a => FromHttpApiData (Fixed a) Source # | Note: this instance is not polykinded |
Defined in Web.Internal.HttpApiData | |
(FromHttpApiData a, FromHttpApiData b) => FromHttpApiData (Either a b) Source # |
|
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (Const a b) Source # | Since: http-api-data-0.4.2 |
Defined in Web.Internal.HttpApiData | |
FromHttpApiData a => FromHttpApiData (Tagged b a) Source # | Note: this instance is not polykinded |
Defined in Web.Internal.HttpApiData |
class ToHttpApiData a where Source #
Convert value to HTTP API data.
WARNING: Do not derive this using DeriveAnyClass
as the generated
instance will loop indefinitely.
Minimal complete definition
Methods
toUrlPiece :: a -> Text Source #
Convert to URL path piece.
toEncodedUrlPiece :: a -> Builder Source #
Convert to a URL path piece, making sure to encode any special chars.
The default definition uses
but this may be overriden with a more efficient version.urlEncodeBuilder
False
toHeader :: a -> ByteString Source #
Convert to HTTP header value.
toQueryParam :: a -> Text Source #
Convert to query param value.
toEncodedQueryParam :: a -> Builder Source #
Convert to URL query param,
The default definition uses
but this may be overriden with a more efficient version.urlEncodeBuilder
True
Since: http-api-data-0.5.1
Instances
ToHttpApiData SetCookie Source # | Note: this instance works correctly for alphanumeric name and value
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: SetCookie -> Text Source # toEncodedUrlPiece :: SetCookie -> Builder Source # toHeader :: SetCookie -> ByteString Source # toQueryParam :: SetCookie -> Text Source # | |
ToHttpApiData Void Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Void -> Text Source # toEncodedUrlPiece :: Void -> Builder Source # toHeader :: Void -> ByteString Source # toQueryParam :: Void -> Text Source # toEncodedQueryParam :: Void -> Builder Source # | |
ToHttpApiData All Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: All -> Text Source # toEncodedUrlPiece :: All -> Builder Source # toHeader :: All -> ByteString Source # toQueryParam :: All -> Text Source # toEncodedQueryParam :: All -> Builder Source # | |
ToHttpApiData Any Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Any -> Text Source # toEncodedUrlPiece :: Any -> Builder Source # toHeader :: Any -> ByteString Source # toQueryParam :: Any -> Text Source # toEncodedQueryParam :: Any -> Builder Source # | |
ToHttpApiData Version Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Version -> Text Source # toEncodedUrlPiece :: Version -> Builder Source # toHeader :: Version -> ByteString Source # toQueryParam :: Version -> Text Source # toEncodedQueryParam :: Version -> Builder Source # | |
ToHttpApiData Int16 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int16 -> Text Source # toEncodedUrlPiece :: Int16 -> Builder Source # toHeader :: Int16 -> ByteString Source # toQueryParam :: Int16 -> Text Source # toEncodedQueryParam :: Int16 -> Builder Source # | |
ToHttpApiData Int32 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int32 -> Text Source # toEncodedUrlPiece :: Int32 -> Builder Source # toHeader :: Int32 -> ByteString Source # toQueryParam :: Int32 -> Text Source # toEncodedQueryParam :: Int32 -> Builder Source # | |
ToHttpApiData Int64 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int64 -> Text Source # toEncodedUrlPiece :: Int64 -> Builder Source # toHeader :: Int64 -> ByteString Source # toQueryParam :: Int64 -> Text Source # toEncodedQueryParam :: Int64 -> Builder Source # | |
ToHttpApiData Int8 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int8 -> Text Source # toEncodedUrlPiece :: Int8 -> Builder Source # toHeader :: Int8 -> ByteString Source # toQueryParam :: Int8 -> Text Source # toEncodedQueryParam :: Int8 -> Builder Source # | |
ToHttpApiData Word16 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word16 -> Text Source # toEncodedUrlPiece :: Word16 -> Builder Source # toHeader :: Word16 -> ByteString Source # toQueryParam :: Word16 -> Text Source # toEncodedQueryParam :: Word16 -> Builder Source # | |
ToHttpApiData Word32 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word32 -> Text Source # toEncodedUrlPiece :: Word32 -> Builder Source # toHeader :: Word32 -> ByteString Source # toQueryParam :: Word32 -> Text Source # toEncodedQueryParam :: Word32 -> Builder Source # | |
ToHttpApiData Word64 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word64 -> Text Source # toEncodedUrlPiece :: Word64 -> Builder Source # toHeader :: Word64 -> ByteString Source # toQueryParam :: Word64 -> Text Source # toEncodedQueryParam :: Word64 -> Builder Source # | |
ToHttpApiData Word8 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word8 -> Text Source # toEncodedUrlPiece :: Word8 -> Builder Source # toHeader :: Word8 -> ByteString Source # toQueryParam :: Word8 -> Text Source # toEncodedQueryParam :: Word8 -> Builder Source # | |
ToHttpApiData Ordering Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Ordering -> Text Source # toEncodedUrlPiece :: Ordering -> Builder Source # toHeader :: Ordering -> ByteString Source # toQueryParam :: Ordering -> Text Source # | |
ToHttpApiData Link Source # | |
Defined in Servant.Links Methods toUrlPiece :: Link -> Text Source # toEncodedUrlPiece :: Link -> Builder Source # toHeader :: Link -> ByteString Source # toQueryParam :: Link -> Text Source # toEncodedQueryParam :: Link -> Builder Source # | |
ToHttpApiData Text Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Text -> Text Source # toEncodedUrlPiece :: Text -> Builder Source # toHeader :: Text -> ByteString Source # toQueryParam :: Text -> Text Source # toEncodedQueryParam :: Text -> Builder Source # | |
ToHttpApiData Text Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Text -> Text Source # toEncodedUrlPiece :: Text -> Builder Source # toHeader :: Text -> ByteString Source # toQueryParam :: Text -> Text Source # toEncodedQueryParam :: Text -> Builder Source # | |
ToHttpApiData Day Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Day -> Text Source # toEncodedUrlPiece :: Day -> Builder Source # toHeader :: Day -> ByteString Source # toQueryParam :: Day -> Text Source # toEncodedQueryParam :: Day -> Builder Source # | |
ToHttpApiData Month Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Month -> Text Source # toEncodedUrlPiece :: Month -> Builder Source # toHeader :: Month -> ByteString Source # toQueryParam :: Month -> Text Source # toEncodedQueryParam :: Month -> Builder Source # | |
ToHttpApiData Quarter Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Quarter -> Text Source # toEncodedUrlPiece :: Quarter -> Builder Source # toHeader :: Quarter -> ByteString Source # toQueryParam :: Quarter -> Text Source # toEncodedQueryParam :: Quarter -> Builder Source # | |
ToHttpApiData QuarterOfYear Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: QuarterOfYear -> Text Source # toEncodedUrlPiece :: QuarterOfYear -> Builder Source # toHeader :: QuarterOfYear -> ByteString Source # toQueryParam :: QuarterOfYear -> Text Source # | |
ToHttpApiData DayOfWeek Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: DayOfWeek -> Text Source # toEncodedUrlPiece :: DayOfWeek -> Builder Source # toHeader :: DayOfWeek -> ByteString Source # toQueryParam :: DayOfWeek -> Text Source # | |
ToHttpApiData NominalDiffTime Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: NominalDiffTime -> Text Source # toEncodedUrlPiece :: NominalDiffTime -> Builder Source # toHeader :: NominalDiffTime -> ByteString Source # toQueryParam :: NominalDiffTime -> Text Source # | |
ToHttpApiData UTCTime Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: UTCTime -> Text Source # toEncodedUrlPiece :: UTCTime -> Builder Source # toHeader :: UTCTime -> ByteString Source # toQueryParam :: UTCTime -> Text Source # toEncodedQueryParam :: UTCTime -> Builder Source # | |
ToHttpApiData LocalTime Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: LocalTime -> Text Source # toEncodedUrlPiece :: LocalTime -> Builder Source # toHeader :: LocalTime -> ByteString Source # toQueryParam :: LocalTime -> Text Source # | |
ToHttpApiData TimeOfDay Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: TimeOfDay -> Text Source # toEncodedUrlPiece :: TimeOfDay -> Builder Source # toHeader :: TimeOfDay -> ByteString Source # toQueryParam :: TimeOfDay -> Text Source # | |
ToHttpApiData ZonedTime Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: ZonedTime -> Text Source # toEncodedUrlPiece :: ZonedTime -> Builder Source # toHeader :: ZonedTime -> ByteString Source # toQueryParam :: ZonedTime -> Text Source # | |
ToHttpApiData UUID Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: UUID -> Text Source # toEncodedUrlPiece :: UUID -> Builder Source # toHeader :: UUID -> ByteString Source # toQueryParam :: UUID -> Text Source # toEncodedQueryParam :: UUID -> Builder Source # | |
ToHttpApiData Integer Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Integer -> Text Source # toEncodedUrlPiece :: Integer -> Builder Source # toHeader :: Integer -> ByteString Source # toQueryParam :: Integer -> Text Source # toEncodedQueryParam :: Integer -> Builder Source # | |
ToHttpApiData Natural Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Natural -> Text Source # toEncodedUrlPiece :: Natural -> Builder Source # toHeader :: Natural -> ByteString Source # toQueryParam :: Natural -> Text Source # toEncodedQueryParam :: Natural -> Builder Source # | |
ToHttpApiData String Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: String -> Text Source # toEncodedUrlPiece :: String -> Builder Source # toHeader :: String -> ByteString Source # toQueryParam :: String -> Text Source # toEncodedQueryParam :: String -> Builder Source # | |
ToHttpApiData () Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: () -> Text Source # toEncodedUrlPiece :: () -> Builder Source # toHeader :: () -> ByteString Source # toQueryParam :: () -> Text Source # toEncodedQueryParam :: () -> Builder Source # | |
ToHttpApiData Bool Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Bool -> Text Source # toEncodedUrlPiece :: Bool -> Builder Source # toHeader :: Bool -> ByteString Source # toQueryParam :: Bool -> Text Source # toEncodedQueryParam :: Bool -> Builder Source # | |
ToHttpApiData Char Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Char -> Text Source # toEncodedUrlPiece :: Char -> Builder Source # toHeader :: Char -> ByteString Source # toQueryParam :: Char -> Text Source # toEncodedQueryParam :: Char -> Builder Source # | |
ToHttpApiData Double Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Double -> Text Source # toEncodedUrlPiece :: Double -> Builder Source # toHeader :: Double -> ByteString Source # toQueryParam :: Double -> Text Source # toEncodedQueryParam :: Double -> Builder Source # | |
ToHttpApiData Float Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Float -> Text Source # toEncodedUrlPiece :: Float -> Builder Source # toHeader :: Float -> ByteString Source # toQueryParam :: Float -> Text Source # toEncodedQueryParam :: Float -> Builder Source # | |
ToHttpApiData Int Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int -> Text Source # toEncodedUrlPiece :: Int -> Builder Source # toHeader :: Int -> ByteString Source # toQueryParam :: Int -> Text Source # toEncodedQueryParam :: Int -> Builder Source # | |
ToHttpApiData Word Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word -> Text Source # toEncodedUrlPiece :: Word -> Builder Source # toHeader :: Word -> ByteString Source # toQueryParam :: Word -> Text Source # toEncodedQueryParam :: Word -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (First a) Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: First a -> Text Source # toEncodedUrlPiece :: First a -> Builder Source # toHeader :: First a -> ByteString Source # toQueryParam :: First a -> Text Source # toEncodedQueryParam :: First a -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (Last a) Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Last a -> Text Source # toEncodedUrlPiece :: Last a -> Builder Source # toHeader :: Last a -> ByteString Source # toQueryParam :: Last a -> Text Source # toEncodedQueryParam :: Last a -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (Max a) Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Max a -> Text Source # toEncodedUrlPiece :: Max a -> Builder Source # toHeader :: Max a -> ByteString Source # toQueryParam :: Max a -> Text Source # toEncodedQueryParam :: Max a -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (Min a) Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Min a -> Text Source # toEncodedUrlPiece :: Min a -> Builder Source # toHeader :: Min a -> ByteString Source # toQueryParam :: Min a -> Text Source # toEncodedQueryParam :: Min a -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (Identity a) Source # | Since: http-api-data-0.4.2 |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Identity a -> Text Source # toEncodedUrlPiece :: Identity a -> Builder Source # toHeader :: Identity a -> ByteString Source # toQueryParam :: Identity a -> Text Source # toEncodedQueryParam :: Identity a -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (First a) Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: First a -> Text Source # toEncodedUrlPiece :: First a -> Builder Source # toHeader :: First a -> ByteString Source # toQueryParam :: First a -> Text Source # toEncodedQueryParam :: First a -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (Last a) Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Last a -> Text Source # toEncodedUrlPiece :: Last a -> Builder Source # toHeader :: Last a -> ByteString Source # toQueryParam :: Last a -> Text Source # toEncodedQueryParam :: Last a -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (Dual a) Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Dual a -> Text Source # toEncodedUrlPiece :: Dual a -> Builder Source # toHeader :: Dual a -> ByteString Source # toQueryParam :: Dual a -> Text Source # toEncodedQueryParam :: Dual a -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (Product a) Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Product a -> Text Source # toEncodedUrlPiece :: Product a -> Builder Source # toHeader :: Product a -> ByteString Source # toQueryParam :: Product a -> Text Source # toEncodedQueryParam :: Product a -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (Sum a) Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Sum a -> Text Source # toEncodedUrlPiece :: Sum a -> Builder Source # toHeader :: Sum a -> ByteString Source # toQueryParam :: Sum a -> Text Source # toEncodedQueryParam :: Sum a -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (Maybe a) Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Maybe a -> Text Source # toEncodedUrlPiece :: Maybe a -> Builder Source # toHeader :: Maybe a -> ByteString Source # toQueryParam :: Maybe a -> Text Source # toEncodedQueryParam :: Maybe a -> Builder Source # | |
HasResolution a => ToHttpApiData (Fixed a) Source # | Note: this instance is not polykinded |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Fixed a -> Text Source # toEncodedUrlPiece :: Fixed a -> Builder Source # toHeader :: Fixed a -> ByteString Source # toQueryParam :: Fixed a -> Text Source # toEncodedQueryParam :: Fixed a -> Builder Source # | |
(ToHttpApiData a, ToHttpApiData b) => ToHttpApiData (Either a b) Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Either a b -> Text Source # toEncodedUrlPiece :: Either a b -> Builder Source # toHeader :: Either a b -> ByteString Source # toQueryParam :: Either a b -> Text Source # toEncodedQueryParam :: Either a b -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (Const a b) Source # | Since: http-api-data-0.4.2 |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Const a b -> Text Source # toEncodedUrlPiece :: Const a b -> Builder Source # toHeader :: Const a b -> ByteString Source # toQueryParam :: Const a b -> Text Source # toEncodedQueryParam :: Const a b -> Builder Source # | |
ToHttpApiData a => ToHttpApiData (Tagged b a) Source # | Note: this instance is not polykinded |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Tagged b a -> Text Source # toEncodedUrlPiece :: Tagged b a -> Builder Source # toHeader :: Tagged b a -> ByteString Source # toQueryParam :: Tagged b a -> Text Source # toEncodedQueryParam :: Tagged b a -> Builder Source # |
Classes and instances for types that can be converted to and from HTTP API data.
Experimental modules
General Authentication
Links
Arguments
:: (IsElem endpoint api, HasLink endpoint) | |
=> Proxy api | The whole API that this endpoint is a part of |
-> Proxy endpoint | The API endpoint you would like to point to |
-> MkLink endpoint Link |
Create a valid (by construction) relative URI with query params.
This function will only typecheck if endpoint
is part of the API api
Represents a general universal resource identifier using its component parts.
For example, for the URI
foo://anonymous@www.haskell.org:42/ghc?query#frag
the components are:
Constructors
URI | |
Instances
FromJSON URI Source # | Since: aeson-2.2.0.0 | ||||
FromJSONKey URI Source # | Since: aeson-2.2.0.0 | ||||
Defined in Data.Aeson.Types.FromJSON Methods | |||||
ToJSON URI Source # | Since: aeson-2.2.0.0 | ||||
ToJSONKey URI Source # | Since: aeson-2.2.0.0 | ||||
Defined in Data.Aeson.Types.ToJSON | |||||
NFData URI Source # | |||||
Defined in Network.URI | |||||
Data URI Source # | |||||
Defined in Network.URI Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> URI -> c URI # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c URI # dataTypeOf :: URI -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c URI) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c URI) # gmapT :: (forall b. Data b => b -> b) -> URI -> URI # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> URI -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> URI -> r # gmapQ :: (forall d. Data d => d -> u) -> URI -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> URI -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> URI -> m URI # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> URI -> m URI # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> URI -> m URI # | |||||
Generic URI Source # | |||||
Defined in Network.URI Associated Types
| |||||
Show URI Source # | |||||
Eq URI Source # | |||||
Ord URI Source # | |||||
Lift URI Source # | |||||
type Rep URI Source # | |||||
Defined in Network.URI type Rep URI = D1 ('MetaData "URI" "Network.URI" "network-uri-2.6.4.2-EJ2U5kfgADg5BdbDj7oONH" 'False) (C1 ('MetaCons "URI" 'PrefixI 'True) ((S1 ('MetaSel ('Just "uriScheme") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "uriAuthority") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe URIAuth))) :*: (S1 ('MetaSel ('Just "uriPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: (S1 ('MetaSel ('Just "uriQuery") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "uriFragment") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))))) |
type family IsElem endpoint api where ... Source #
Closed type family, check if endpoint
is within api
.
Uses
if it exhausts all other options.IsElem'
>>>
ok (Proxy :: Proxy (IsElem ("hello" :> Get '[JSON] Int) SampleAPI))
OK
>>>
ok (Proxy :: Proxy (IsElem ("bye" :> Get '[JSON] Int) SampleAPI))
... ... Could not ... ...
An endpoint is considered within an api even if it is missing combinators that don't affect the URL:
>>>
ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (Header "h" Bool :> Get '[JSON] Int)))
OK
>>>
ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (ReqBody '[JSON] Bool :> Get '[JSON] Int)))
OK
- N.B.:*
IsElem a b
can be seen as capturing the notion of whether the URL represented bya
would match the URL represented byb
, *not* whether a request represented bya
matches the endpoints servingb
(for the latter, useIsIn
).
Equations
IsElem e (sa :<|> sb) = Or (IsElem e sa) (IsElem e sb) | |
IsElem (e :> sa) (e :> sb) = IsElem sa sb | |
IsElem sa (Header sym x :> sb) = IsElem sa sb | |
IsElem sa (Header' mods sym x :> sb) = IsElem sa sb | |
IsElem sa (ReqBody y x :> sb) = IsElem sa sb | |
IsElem (CaptureAll z y :> sa) (CaptureAll x y :> sb) = IsElem sa sb | |
IsElem (Capture z y :> sa) (Capture x y :> sb) = IsElem sa sb | |
IsElem sa (QueryParam x y :> sb) = IsElem sa sb | |
IsElem sa (QueryParams x y :> sb) = IsElem sa sb | |
IsElem sa (QueryFlag x :> sb) = IsElem sa sb | |
IsElem sa (Fragment x :> sb) = IsElem sa sb | |
IsElem (Verb m s ct typ) (Verb m s ct' typ) = IsSubList ct ct' | |
IsElem e e = () | |
IsElem e (NamedRoutes rs) = IsElem e (ToServantApi rs) | |
IsElem e a = IsElem' e a |
type family IsElem' a s Source #
You may use this type family to tell the type checker that your custom
type may be skipped as part of a link. This is useful for things like
that are optional in a URI and do not affect them if they are
omitted.QueryParam
>>>
data CustomThing
>>>
type instance IsElem' e (CustomThing :> s) = IsElem e s
Note that
is called, which will mutually recurse back to IsElem
if it exhausts all other options again.IsElem'
Once you have written a HasLink
instance for CustomThing
you are ready to go.
class HasLink (endpoint :: k) where Source #
Construct a toLink for an endpoint.
Methods
Instances
HasLink EmptyAPI Source # | |
HasLink Raw Source # | |
HasLink RawM Source # | |
(TypeError (NoInstanceFor (HasLink api)) :: Constraint) => HasLink (api :: k) Source # | |
(HasLink (ToServantApi routes), forall a. GLink routes a, ErrorIfNoGeneric routes) => HasLink (NamedRoutes routes :: Type) Source # | |
Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (NamedRoutes routes) -> Link -> MkLink (NamedRoutes routes) a Source # | |
(HasLink a, HasLink b) => HasLink (a :<|> b :: Type) Source # | |
HasLink (NoContentVerb m :: Type) Source # | |
Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (NoContentVerb m) -> Link -> MkLink (NoContentVerb m) a Source # | |
(TypeError (PartialApplication (HasLink :: Type -> Constraint) arr) :: Constraint) => HasLink (arr :> sub :: Type) Source # | |
(KnownSymbol sym, HasLink sub) => HasLink (sym :> sub :: Type) Source # | |
HasLink sub => HasLink (HttpVersion :> sub :: Type) Source # | |
Defined in Servant.Links | |
HasLink sub => HasLink (BasicAuth realm a :> sub :: Type) Source # | |
(ToHttpApiData v, HasLink sub) => HasLink (Capture' mods sym v :> sub :: Type) Source # | |
(ToHttpApiData v, HasLink sub) => HasLink (CaptureAll sym v :> sub :: Type) Source # | |
Defined in Servant.Links | |
HasLink sub => HasLink (Description s :> sub :: Type) Source # | |
Defined in Servant.Links | |
HasLink sub => HasLink (Summary s :> sub :: Type) Source # | |
HasLink sub => HasLink (AuthProtect tag :> sub :: Type) Source # | |
Defined in Servant.Links | |
(HasLink sub, ToHttpApiData v) => HasLink (Fragment v :> sub :: Type) Source # | |
HasLink sub => HasLink (Header' mods sym a :> sub :: Type) Source # | |
HasLink sub => HasLink (IsSecure :> sub :: Type) Source # | |
(KnownSymbol sym, HasLink sub) => HasLink (QueryFlag sym :> sub :: Type) Source # | |
(KnownSymbol sym, ToHttpApiData v, HasLink sub, SBoolI (FoldRequired mods)) => HasLink (QueryParam' mods sym v :> sub :: Type) Source # | |
Defined in Servant.Links | |
(KnownSymbol sym, ToHttpApiData v, HasLink sub) => HasLink (QueryParams sym v :> sub :: Type) Source # | |
Defined in Servant.Links | |
HasLink sub => HasLink (RemoteHost :> sub :: Type) Source # | |
Defined in Servant.Links | |
HasLink sub => HasLink (ReqBody' mods ct a :> sub :: Type) Source # | |
HasLink sub => HasLink (StreamBody' mods framing ct a :> sub :: Type) Source # | |
Defined in Servant.Links | |
HasLink sub => HasLink (WithResource res :> sub :: Type) Source # | |
Defined in Servant.Links | |
HasLink sub => HasLink (Vault :> sub :: Type) Source # | |
(TypeError (NoInstanceForSub (HasLink :: Type -> Constraint) ty) :: Constraint) => HasLink (ty :> sub :: Type) Source # | |
HasLink (UVerb m ct a :: Type) Source # | |
HasLink sub => HasLink (WithNamedContext name context sub :: Type) Source # | |
Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (WithNamedContext name context sub) -> Link -> MkLink (WithNamedContext name context sub) a Source # | |
HasLink (Verb m s ct a :: Type) Source # | |
HasLink (Stream m status fr ct a :: Type) Source # | |
A safe link datatype.
The only way of constructing a Link
is using safeLink
, which means any
Link
is guaranteed to be part of the mentioned API.
Instances
Show Link Source # | |
ToHttpApiData Link Source # | |
Defined in Servant.Links Methods toUrlPiece :: Link -> Text Source # toEncodedUrlPiece :: Link -> Builder Source # toHeader :: Link -> ByteString Source # toQueryParam :: Link -> Text Source # toEncodedQueryParam :: Link -> Builder Source # |
type family MkLink (endpoint :: k) a Source #
Instances
type MkLink EmptyAPI a Source # | |
Defined in Servant.Links | |
type MkLink Raw a Source # | |
Defined in Servant.Links | |
type MkLink RawM a Source # | |
Defined in Servant.Links | |
type MkLink (NamedRoutes routes :: Type) a Source # | |
Defined in Servant.Links | |
type MkLink (a :<|> b :: Type) r Source # | |
type MkLink (NoContentVerb m :: Type) r Source # | |
Defined in Servant.Links | |
type MkLink (arr :> sub :: Type) _1 Source # | |
Defined in Servant.Links type MkLink (arr :> sub :: Type) _1 = TypeError (PartialApplication (HasLink :: Type -> Constraint) arr) :: Type | |
type MkLink (sym :> sub :: Type) a Source # | |
Defined in Servant.Links | |
type MkLink (HttpVersion :> sub :: Type) a Source # | |
Defined in Servant.Links | |
type MkLink (BasicAuth realm a :> sub :: Type) r Source # | |
type MkLink (Capture' mods sym v :> sub :: Type) a Source # | |
type MkLink (CaptureAll sym v :> sub :: Type) a Source # | |
Defined in Servant.Links | |
type MkLink (Description s :> sub :: Type) a Source # | |
Defined in Servant.Links | |
type MkLink (Summary s :> sub :: Type) a Source # | |
type MkLink (AuthProtect tag :> sub :: Type) a Source # | |
Defined in Servant.Links | |
type MkLink (Fragment v :> sub :: Type) a Source # | |
type MkLink (Header' mods sym a :> sub :: Type) r Source # | |
type MkLink (IsSecure :> sub :: Type) a Source # | |
type MkLink (QueryFlag sym :> sub :: Type) a Source # | |
type MkLink (QueryParam' mods sym v :> sub :: Type) a Source # | |
Defined in Servant.Links type MkLink (QueryParam' mods sym v :> sub :: Type) a = If (FoldRequired mods) v (Maybe v) -> MkLink sub a | |
type MkLink (QueryParams sym v :> sub :: Type) a Source # | |
Defined in Servant.Links | |
type MkLink (RemoteHost :> sub :: Type) a Source # | |
Defined in Servant.Links | |
type MkLink (ReqBody' mods ct a :> sub :: Type) r Source # | |
type MkLink (StreamBody' mods framing ct a :> sub :: Type) r Source # | |
Defined in Servant.Links | |
type MkLink (WithResource res :> sub :: Type) a Source # | |
Defined in Servant.Links | |
type MkLink (Vault :> sub :: Type) a Source # | |
type MkLink (UVerb m ct a :: Type) r Source # | |
Defined in Servant.Links | |
type MkLink (WithNamedContext name context sub :: Type) a Source # | |
Defined in Servant.Links | |
type MkLink (Verb m s ct a :: Type) r Source # | |
Defined in Servant.Links | |
type MkLink (Stream m status fr ct a :: Type) r Source # | |
Defined in Servant.Links |
Type-safe internal URIs
Re-exports
type family If (cond :: Bool) (tru :: k) (fls :: k) :: k where ... #
Type-level If. If True a b
==> a
; If False a b
==> b
data SBool (b :: Bool) where Source #
Instances
EqP SBool Source # | Since: singleton-bool-0.1.7 |
GNFData SBool Source # | Since: singleton-bool-0.1.6 |
GCompare SBool Source # | Since: singleton-bool-0.1.6 |
GEq SBool Source # |
Since: singleton-bool-0.1.6 |
GRead SBool Source # |
Since: singleton-bool-0.1.6 |
Defined in Data.Singletons.Bool | |
GShow SBool Source # |
Since: singleton-bool-0.1.6 |
Defined in Data.Singletons.Bool | |
OrdP SBool Source # | Since: singleton-bool-0.1.7 |
SBoolI b => Boring (SBool b) Source # | Since: singleton-bool-0.1.6 |
Defined in Data.Singletons.Bool | |
NFData (SBool b) Source # | Since: singleton-bool-0.1.6 |
Defined in Data.Singletons.Bool | |
Show (SBool b) Source # | Since: singleton-bool-0.1.5 |
Eq (SBool b) Source # | Since: singleton-bool-0.1.5 |
Ord (SBool b) Source # | Since: singleton-bool-0.1.5 |
Defined in Data.Singletons.Bool |