| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Serv.Internal.Api
Description
Types, but really kinds, which represent the structure of an API.
- data Api star where
- data Method star where
- Method :: Verb -> [Pair HeaderName star] -> Body star -> Method star
- CaptureBody :: [star] -> star -> Method star -> Method star
- CaptureHeaders :: [Pair HeaderName star] -> Method star -> Method star
- CaptureQuery :: [Pair Symbol star] -> Method star -> Method star
- data Body star where
- data Path star where
Documentation
Apis describe collections of HTTP endpoints accessible at
various segmented Paths.
An Endpoint describes a root API which responds
only to requests with empty paths. It matches on HTTP Methods
which demand Verbs, HeaderNames, and Bodys.
Endpoint differs from OneOf in that it can only choose between
possible methods and automatically provides an OPTIONS response.
Apis consist of many sub-Apis which are attempted sequentially.
expresses this sequential search along a set of sub-OneOf choicesApi
choices.
Raw enables the use of standard Applications within an Api.
These cannot be examined further through type analysis, but they are a
common use case.
Qualify an API using a series of Path qualifiers.
Constructors
| Endpoint :: [Method star] -> Api star | |
| OneOf :: [Api star] -> Api star | |
| Raw :: Api star | |
| (:>) :: Path star -> Api star -> Api star infixr 5 |
Instances
| Handling (Api star) (Raw star) Source # | |
| (VerbsOf [Method *] methods, HeadersReturnedBy methods, HeadersExpectedOf methods, Handling [Method *] methods) => Handling (Api *) (Endpoint * methods) Source # | |
| Handling [Api star] apis => Handling (Api star) (OneOf star apis) Source # | |
| (URIDecode v, Handling (Api *) api) => Handling (Api *) ((:>) * (Seg * n v) api) Source # | |
| (HeaderDecode n v, Handling (Api *) api) => Handling (Api *) ((:>) * (Header * n v) api) Source # | |
| (Handling (Api *) api, CorsPolicy p) => Handling (Api *) ((:>) * (Cors * p) api) Source # | |
| (ReflectName n, KnownSymbol v, Handling (Api star) api) => Handling (Api star) ((:>) star (HeaderAs star n v) api) Source # | |
| Handling (Api star) api => Handling (Api star) ((:>) star (Wildcard star) api) Source # | |
| (KnownSymbol s, Handling (Api star) api) => Handling (Api star) ((:>) star (Const star s) api) Source # | |
| type Impl (Api star) (Raw star) m Source # | |
| type Impl (Api *) (Endpoint * methods) m Source # | |
| type Impl (Api star) (OneOf star apis) m Source # | |
| type Impl (Api *) ((:>) * (Seg * n v) api) m Source # | |
| type Impl (Api *) ((:>) * (Header * n v) api) m Source # | |
| type Impl (Api *) ((:>) * (Cors * p) api) m Source # | |
| type Impl (Api star) ((:>) star (HeaderAs star s v) api) m Source # | |
| type Impl (Api star) ((:>) star (Wildcard star) api) m Source # | |
| type Impl (Api star) ((:>) star (Const star s) api) m Source # | |
data Method star where Source #
A Method is a single HTTP verb response handled at a given Endpoint.
In order to complete a Method's operation it may demand data from the
request such as headers or the request body.
A "core" Method definition which describes the Verb it responds
to along with a set of response headers and a chance to attach a
response Body.
Augment a Method to include requirements of a request body.
Augment a Method to include requirements of request header values.
Constructors
| Method :: Verb -> [Pair HeaderName star] -> Body star -> Method star | |
| CaptureBody :: [star] -> star -> Method star -> Method star | |
| CaptureHeaders :: [Pair HeaderName star] -> Method star -> Method star | |
| CaptureQuery :: [Pair Symbol star] -> Method star -> Method star |
Instances
Method responses may opt to include a response body or not.
Return a response body by specifying a set of content-types and a value to derive the body from.
A response with an empty body
Generalized path segments match against data in the request.
Matches if the request has a non-empty remaining path and the next segment matches exactly
Matches if the request has a given header and its value matches exactly (!)
Matches if the request has a non-empty remaining path. The next segment is "captured", provided to the server implementation.
Always matches, "capturing" the value of a header, or Nothing if
the header fails to exist.
Always matches, "captures" the remaining path segments as a list of text values. May just capture the empty list.
Always matches, "captures" the existence of a query flag by
returning True if the flag is provided and False otherwise.
Always matches, "capturing" the value of a query parameter.