-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Dependently typed API server framework
--
-- Please see README.md
@package serv
@version 0.1.0.0
module Serv.Internal.Verb
data Verb
DELETE :: Verb
GET :: Verb
HEAD :: Verb
OPTIONS :: Verb
PATCH :: Verb
POST :: Verb
PUT :: Verb
standardName :: Verb -> Method
class ReflectVerb (v :: Verb)
reflectVerb :: ReflectVerb v => Proxy v -> Verb
instance GHC.Read.Read Serv.Internal.Verb.Verb
instance GHC.Show.Show Serv.Internal.Verb.Verb
instance GHC.Classes.Ord Serv.Internal.Verb.Verb
instance GHC.Classes.Eq Serv.Internal.Verb.Verb
instance Serv.Internal.Verb.ReflectVerb 'Serv.Internal.Verb.GET
instance Serv.Internal.Verb.ReflectVerb 'Serv.Internal.Verb.HEAD
instance Serv.Internal.Verb.ReflectVerb 'Serv.Internal.Verb.POST
instance Serv.Internal.Verb.ReflectVerb 'Serv.Internal.Verb.PUT
instance Serv.Internal.Verb.ReflectVerb 'Serv.Internal.Verb.PATCH
instance Serv.Internal.Verb.ReflectVerb 'Serv.Internal.Verb.DELETE
instance Serv.Internal.Verb.ReflectVerb 'Serv.Internal.Verb.OPTIONS
module Serv.Internal.Server.Error
-- | Errors which arise during the "handling" portion of dealing with a
-- response.
data RoutingError
NotFound :: RoutingError
BadRequest :: (Maybe String) -> RoutingError
UnsupportedMediaType :: RoutingError
MethodNotAllowed :: [Verb] -> RoutingError
-- | An ignorable error is one which backtracks the routing search instead
-- of forcing a response.
ignorable :: RoutingError -> Bool
module Serv.Internal.Server.Config
data Config
Config :: Config
defaultConfig :: Config
module Serv.Internal.RawText
-- | RawText extracts as, like the name suggests, raw text from URI
-- segments and header values.
--
-- It exists as a default value for extensibility of typeclasses like
-- HeaderDecode and HeaderEncode
newtype RawText
RawText :: Text -> RawText
[getRawText] :: RawText -> Text
instance Data.String.IsString Serv.Internal.RawText.RawText
instance GHC.Base.Monoid Serv.Internal.RawText.RawText
instance GHC.Show.Show Serv.Internal.RawText.RawText
instance GHC.Read.Read Serv.Internal.RawText.RawText
instance GHC.Classes.Ord Serv.Internal.RawText.RawText
instance GHC.Classes.Eq Serv.Internal.RawText.RawText
module Serv.Internal.URI
class URIEncode a
uriEncode :: URIEncode a => a -> Text
class URIDecode a
uriDecode :: URIDecode a => Text -> Either String a
fromByteString :: URIDecode a => ByteString -> Either String a
instance Serv.Internal.URI.URIDecode Serv.Internal.RawText.RawText
module Serv.URI
class URIEncode a
uriEncode :: URIEncode a => a -> Text
class URIDecode a
uriDecode :: URIDecode a => Text -> Either String a
module Serv.Internal.Pair
-- | Equivalent to a tuple at both the type and kind levels, but has a
-- nicer syntax!
data Pair a b
(:::) :: a -> b -> Pair a b
module Serv.Internal.Rec
-- | An HList collecting heterogenous types matched up to labeling
-- information
data Rec rs
[Nil] :: Rec '[]
[Cons] :: ty -> Rec rs -> Rec ((name ::: ty) : rs)
-- | Append a new header value on to a record
(-:) :: Proxy name -> ty -> Rec rs -> Rec ((name ::: ty) : rs)
class Elem name e es
eGet :: Elem name e es => Rec es -> Tagged name e
eMap :: Elem name e es => Tagged name (e -> e) -> Rec es -> Rec es
class Subset rs qs
project :: Subset rs qs => Rec qs -> Rec rs
class RecordIso rs qs
reorder :: RecordIso rs qs => Rec rs -> Rec qs
instance forall a (name :: a) e (rs :: [Serv.Internal.Pair.Pair a *]). Serv.Internal.Rec.Elem name e (name 'Serv.Internal.Pair.::: e : rs)
instance forall a k (name :: k) e (rs :: [Serv.Internal.Pair.Pair a *]) (r :: Serv.Internal.Pair.Pair a *). Serv.Internal.Rec.Elem name e rs => Serv.Internal.Rec.Elem name e (r : rs)
instance forall a a1 (qs :: [Serv.Internal.Pair.Pair a1 *]). Serv.Internal.Rec.Subset '[] qs
instance forall a a1 (name :: a1) r (qs :: [Serv.Internal.Pair.Pair a *]) (rs :: [Serv.Internal.Pair.Pair a1 *]). (Serv.Internal.Rec.Elem name r qs, Serv.Internal.Rec.Subset rs qs) => Serv.Internal.Rec.Subset (name 'Serv.Internal.Pair.::: r : rs) qs
instance forall a a1 (rs :: [Serv.Internal.Pair.Pair a1 *]) (qs :: [Serv.Internal.Pair.Pair a *]). (Serv.Internal.Rec.Subset rs qs, Serv.Internal.Rec.Subset qs rs) => Serv.Internal.Rec.RecordIso rs qs
module Serv.Internal.Query
class QueryEncode (s :: Symbol) a
queryEncode :: QueryEncode s a => Proxy s -> a -> Maybe Text
class QueryDecode (s :: Symbol) a
queryDecode :: QueryDecode s a => Proxy s -> Maybe Text -> Either String a
-- | Given a record of headers, encode them into a list of header pairs.
class ReflectQuery query
reflectQuery :: ReflectQuery query => Rec query -> Query
instance Serv.Internal.Query.QueryEncode s Serv.Internal.RawText.RawText
instance Serv.Internal.Query.QueryDecode s Serv.Internal.RawText.RawText
instance Serv.Internal.Query.ReflectQuery '[]
instance (GHC.TypeLits.KnownSymbol s, Serv.Internal.Query.QueryEncode s a, Serv.Internal.Query.ReflectQuery query) => Serv.Internal.Query.ReflectQuery (s 'Serv.Internal.Pair.::: a : query)
module Serv.Internal.MediaType
class HasMediaType ty
mediaType :: HasMediaType ty => Proxy ty -> MediaType
class HasMediaType ty => MimeEncode ty val
mimeEncode :: MimeEncode ty val => Proxy ty -> val -> ByteString
class HasMediaType ty => MimeDecode ty val
mimeDecode :: MimeDecode ty val => Proxy ty -> ByteString -> Either String val
negotiateContent :: ReflectEncoders ctypes a => Proxy ctypes -> [Quality MediaType] -> a -> Maybe (MediaType, ByteString)
-- | Similar to negotiateContent but will always attempt to provide
-- the first content type the server offers if nothing is acceptable.
-- Still fails when no content types are offered (what's going on?)
negotiateContentAlways :: ReflectEncoders ctypes a => Proxy ctypes -> [Quality MediaType] -> a -> Maybe (MediaType, ByteString)
class ReflectEncoders cts ty
reflectEncoders :: ReflectEncoders cts ty => Proxy cts -> [(MediaType, ty -> ByteString)]
tryDecode :: ReflectDecoders ctypes a => Proxy ctypes -> ByteString -> ByteString -> Maybe (Either String a)
class ReflectDecoders cts ty
reflectDecoders :: ReflectDecoders cts ty => Proxy cts -> [(MediaType, ByteString -> Either String ty)]
instance Serv.Internal.MediaType.ReflectEncoders '[] ty
instance forall a (cts :: [a]) ty (ct :: a). (Serv.Internal.MediaType.ReflectEncoders cts ty, Serv.Internal.MediaType.MimeEncode ct ty) => Serv.Internal.MediaType.ReflectEncoders (ct : cts) ty
instance Serv.Internal.MediaType.ReflectDecoders '[] ty
instance forall a (ct :: a) ty (cts :: [a]). (Serv.Internal.MediaType.MimeDecode ct ty, Serv.Internal.MediaType.ReflectDecoders cts ty) => Serv.Internal.MediaType.ReflectDecoders (ct : cts) ty
module Serv.Internal.Header.Name
-- | The variant (name and meaning) of a HTTP header.
--
-- An incomplete listing of most permanant headers, a selection of
-- provisional ones, and one or two non-standard headers. Generally, any
-- header desired can be specified using the Name constructor.
--
-- Used only as their DataKinds types system.
data HeaderName
-- | Inject an arbitatry symbol in as a HeaderName. This can be used
-- to implement any sort of custom header
HeaderName :: Symbol -> HeaderName
-- | Used to specify directives that must be obeyed by all caching
-- mechanisms along the request-response chain. Tells all caching
-- mechanisms from server to client whether they may cache this object.
-- It is measured in seconds
--
-- Cache-Control: no-cache
CacheControl :: HeaderName
-- | Control options for the current connection and list of hop-by-hop
-- request fields
--
-- Connection: keep-alive Connection: Upgrade
Connection :: HeaderName
-- | The length of the request body in octets (8-bit bytes)
--
-- Content-Length: 348
ContentLength :: HeaderName
-- | The MIME type of the body of the request (used with POST and PUT
-- requests)
--
-- Content-Type: application/x-www-form-urlencoded
ContentType :: HeaderName
-- | The date and time that the message was sent (in HTTP-date
-- format as defined by RFC 7231 Date/Time Formats)
--
-- Date: Tue, 15 Nov 1994 08:12:31 GMT
Date :: HeaderName
-- | Implementation-specific fields that may have various effects anywhere
-- along the request-response chain.
--
-- Pragma: no-cache
Pragma :: HeaderName
-- | Ask the server to upgrade to another protocol.
--
-- Upgrade: HTTP2.0, SHTTP1.3, IRC6.9, RTAx11
Upgrade :: HeaderName
-- | Informs the server of proxies through which the request was sent.
--
-- Via: 1.0 fred, 1.1 example.com (Apache/1.1)
Via :: HeaderName
-- | A general warning about possible problems with the entity body.
--
-- Warning: 199 Miscellaneous warning
Warning :: HeaderName
-- | Content-Types that are acceptable for the response.
--
-- Accept: text/plain
Accept :: HeaderName
-- | Character sets that are acceptable
--
-- Accept-Charset: utf-8
AcceptCharset :: HeaderName
-- | List of acceptable encodings.
--
-- Accept-Encoding: gzip, deflate
AcceptEncoding :: HeaderName
-- | List of acceptable human languages for response.
--
-- Accept-Language: en-US
AcceptLanguage :: HeaderName
-- | Used when issuing a preflight request to let the server know what HTTP
-- method will be used when the actual request is made.
--
-- Access-Control-Request-Method: POST
AccessControlRequestMethod :: HeaderName
-- | Used when issuing a preflight request to let the server know what HTTP
-- headers will be used when the actual request is made.
--
-- Access-Control-Request-Headers: X-PINGOTHER
AccessControlRequestHeaders :: HeaderName
-- | Authentication credentials for HTTP authentication
--
-- Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Authorization :: HeaderName
-- | An HTTP cookie previously sent by the server with Set-Cookie (below)
--
-- Cookie: $Version=1; Skin=new;
Cookie :: HeaderName
-- | Indicates that particular server behaviors are required by the client
--
-- Expect: 100-continue
Expect :: HeaderName
-- | The email address of the user making the request
--
-- From: user@example.com
From :: HeaderName
-- | The domain name of the server (for virtual hosting), and the TCP port
-- number on which the server is listening. The port number may be
-- omitted if the port is the standard port for the service requested.
--
-- Host: en.wikipedia.org:80 Host: en.wikipedia.org
Host :: HeaderName
-- | Only perform the action if the client supplied entity matches the same
-- entity on the server. This is mainly for methods like PUT to only
-- update a resource if it has not been modified since the user last
-- updated it.
--
-- If-Match: "737060cd8c284d8af7ad3082f209582d"
IfMatch :: HeaderName
-- | Allows a 304 Not Modified to be returned if content is unchanged
--
-- If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
IfModifiedSince :: HeaderName
-- | Allows a 304 Not Modified to be returned if content is unchanged, see
-- HTTP ETag
--
-- If-None-Match: "737060cd8c284d8af7ad3082f209582d"
IfNoneMatch :: HeaderName
-- | If the entity is unchanged, send me the part(s) that I am missing;
-- otherwise, send me the entire new entity
--
-- If-Range: "737060cd8c284d8af7ad3082f209582d"
IfRange :: HeaderName
-- | Only send the response if the entity has not been modified since a
-- specific time.
--
-- If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT
IfUnmodifiedSince :: HeaderName
-- | Limit the number of times the message can be forwarded through proxies
-- or gateways.
--
-- Max-Forwards: 10
MaxForwards :: HeaderName
-- | Initiates a request for cross-origin resource sharing (asks server for
-- an 'Access-Control-Allow-Origin' response field).
--
-- Origin: http://www.example-social-network.com
Origin :: HeaderName
-- | Authorization credentials for connecting to a proxy.
--
-- Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
ProxyAuthorization :: HeaderName
-- | Request only part of an entity. Bytes are numbered from 0.
--
-- Range: bytes=500-999
Range :: HeaderName
-- | This is the address of the previous web page from which a link to the
-- currently requested page was followed. (The word “referrer” has been
-- misspelled in the RFC as well as in most implementations to the point
-- that it has become standard usage and is considered correct
-- terminology)
--
-- Referer: http://en.wikipedia.org/wiki/Main_Page
Referer :: HeaderName
-- | The transfer encodings the user agent is willing to accept: the same
-- values as for the response header field Transfer-Encoding can be used,
-- plus the "trailers" value (related to the "chunked" transfer method)
-- to notify the server it expects to receive additional fields in the
-- trailer after the last, zero-sized, chunk.
--
-- TE: trailers, deflate
TE :: HeaderName
-- | The user agent string of the user agent
--
-- User-Agent: Mozilla5.0 (X11; Linux x86_64; rv:12.0)
-- Gecko20100101 Firefox/21.0
UserAgent :: HeaderName
-- | A de facto standard for identifying the originating IP address of a
-- client connecting to a web server through an HTTP proxy or load
-- balancer
--
-- X-Forwarded-For: client1, proxy1, proxy2 X-Forwarded-For:
-- 129.78.138.66, 129.78.64.103
XForwardedFor :: HeaderName
-- | A de facto standard for identifying the original host requested by the
-- client in the Host HTTP request header, since the host name and/or
-- port of the reverse proxy (load balancer) may differ from the origin
-- server handling the request.
--
-- X-Forwarded-Host: en.wikipedia.org:80 X-Forwarded-Host:
-- en.wikipedia.org
XForwardedHost :: HeaderName
-- | A de facto standard for identifying the originating protocol of an
-- HTTP request, since a reverse proxy (or a load balancer) may
-- communicate with a web server using HTTP even if the request to the
-- reverse proxy is HTTPS.
XForwardedProto :: HeaderName
-- | Used to prevent cross-site request forgery.
--
-- X-Csrf-Token: i8XNjC4b8KVok4uw5RftR38Wgp2BFwql
XCsrfToken :: HeaderName
-- | When responding to a CORS request this lists either an origin or
-- * describing the server's CORS policy for the requested
-- resource
--
-- Access-Control-Allow-Origin: * Access-Control-Allow-Origin:
-- http://foo.example Access-Control-Allow-Origin:
-- https://foo.example
AccessControlAllowOrigin :: HeaderName
-- | This header lets a server whitelist headers that browsers are allowed
-- to access.
--
-- Access-Control-Expose-Headers: X-My-Custom-Header,
-- X-Another-Custom-Header
AccessControlExposeHeaders :: HeaderName
-- | This header indicates how long the results of a preflight request can
-- be cached.
--
-- Access-Control-Max-Age: delta-seconds
AccessControlMaxAge :: HeaderName
-- | Indicates whether or not the response to the request can be exposed
-- when the credentials flag is true. When used as part of a response to
-- a preflight request, this indicates whether or not the actual request
-- can be made using credentials. Note that simple GET requests are not
-- preflighted, and so if a request is made for a resource with
-- credentials, if this header is not returned with the resource, the
-- response is ignored by the browser and not returned to web content.
--
-- Access-Control-Allow-Credentials: true | false
AccessControlAllowCredentials :: HeaderName
-- | Specifies the method or methods allowed when accessing the resource.
-- This is used in response to a preflight request.
--
-- Access-Control-Allow-Methods: method[, method]*
AccessControlAllowMethods :: HeaderName
-- | Used in response to a preflight request to indicate which HTTP headers
-- can be used when making the actual request.
AccessControlAllowHeaders :: HeaderName
-- | Specifies which patch document formats this server supports
--
-- Accept-Patch: text/example;charset=utf-8
AcceptPatch :: HeaderName
-- | What partial content range types this server supports via byte serving
--
-- Accept-Ranges: bytes
AcceptRanges :: HeaderName
-- | The age the object has been in a proxy cache in seconds
--
-- Age: 12
Age :: HeaderName
-- | Valid actions for a specified resource. To be used for a 405 Method
-- not allowed
--
-- Allow: GET, HEAD
Allow :: HeaderName
-- | An opportunity to raise a "File Download" dialogue box for a known
-- MIME type with binary format or suggest a filename for dynamic
-- content. Quotes are necessary with special characters.
--
-- Content-Disposition: attachment; filename="fname.ext"
ContentDisposition :: HeaderName
-- | The type of encoding used on the data.
--
-- Content-Encoding: gzip
ContentEncoding :: HeaderName
-- | The natural language or languages of the intended audience for the
-- enclosed content
--
-- Content-Language: da
ContentLanguage :: HeaderName
-- | An alternate location for the returned data
--
-- Content-Location: /index.htm
ContentLocation :: HeaderName
-- | Where in a full body message this partial message belongs
--
-- Content-Range: bytes 21010-47021/47022
ContentRange :: HeaderName
-- | Content Security Policy definition.
--
-- Content-Security-Policy: default-src self
ContentSecurityPolicy :: HeaderName
-- | An identifier for a specific version of a resource, often a message
-- digest
--
-- ETag: "737060cd8c284d8af7ad3082f209582d"
ETag :: HeaderName
-- | Gives the date/time after which the response is considered stale (in
-- HTTP-date format as defined by RFC 7231)
--
-- Expires: Thu, 01 Dec 1994 16:00:00 GMT
Expires :: HeaderName
-- | The last modified date for the requested object (in HTTP-date
-- format as defined by RFC 7231)
--
-- Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
LastModified :: HeaderName
-- | Used to express a typed relationship with another resource, where the
-- relation type is defined by RFC 5988
--
-- Link: /feed; rel="alternate"
Link :: HeaderName
-- | Used in redirection, or when a new resource has been created.
--
-- Location: http://www.w3.org/pub/WWW/People.html
Location :: HeaderName
-- | Request authentication to access the proxy.
--
-- Proxy-Authenticate: Basic
ProxyAuthenticate :: HeaderName
-- | HTTP Public Key Pinning, announces hash of website's authentic TLS
-- certificate
--
-- Public-Key-Pins: max-age=2592000;
-- pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
PublicKeyPins :: HeaderName
-- | If an entity is temporarily unavailable, this instructs the client to
-- try again later. Value could be a specified period of time (in
-- seconds) or a HTTP-date.
--
-- Retry-After: 120 Retry-After: Fri, 07 Nov 2014 23:59:59 GMT
RetryAfter :: HeaderName
-- | An HTTP cookie
--
-- Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1
SetCookie :: HeaderName
-- | A HSTS Policy informing the HTTP client how long to cache the HTTPS
-- only policy and whether this applies to subdomains.
--
-- Strict-Transport-Security: max-age=16070400; includeSubDomains
StrictTransportSecurity :: HeaderName
-- | The Trailer general field value indicates that the given set of header
-- fields is present in the trailer of a message encoded with chunked
-- transfer coding.
--
-- Trailer: Max-Forwards
Trailer :: HeaderName
-- | The form of encoding used to safely transfer the entity to the user.
-- Currently defined methods are: chunked, compress, deflate, gzip,
-- identity.
--
-- Transfer-Encoding: chunked
TransferEncoding :: HeaderName
-- | Tells downstream proxies how to match future request headers to decide
-- whether the cached response can be used rather than requesting a fresh
-- one from the origin server.
--
-- Vary: * Vary: Accept-Language
Vary :: HeaderName
-- | Indicates the authentication scheme that should be used to access the
-- requested entity.
--
-- WWW-Authenticate: Basic
WWWAuthenticate :: HeaderName
-- | Implements reflection of Name types into HeaderName
-- values for runtime use.
class ReflectName (n :: HeaderName)
reflectName :: ReflectName n => proxy n -> HeaderName
cacheControl :: Proxy CacheControl
connection :: Proxy Connection
contentLength :: Proxy ContentLength
contentType :: Proxy ContentType
date :: Proxy Date
pragma :: Proxy Pragma
upgrade :: Proxy Upgrade
via :: Proxy Via
warning :: Proxy Warning
accept :: Proxy Accept
acceptCharset :: Proxy AcceptCharset
acceptEncoding :: Proxy AcceptEncoding
acceptLanguage :: Proxy AcceptLanguage
accessControlRequestMethod :: Proxy AccessControlRequestMethod
accessControlRequestHeaders :: Proxy AccessControlRequestHeaders
authorization :: Proxy Authorization
cookie :: Proxy Cookie
expect :: Proxy Expect
from :: Proxy From
host :: Proxy Host
ifMatch :: Proxy IfMatch
ifModifiedSince :: Proxy IfModifiedSince
ifNoneMatch :: Proxy IfNoneMatch
ifRange :: Proxy IfRange
ifUnmodifiedSince :: Proxy IfUnmodifiedSince
maxForwards :: Proxy MaxForwards
origin :: Proxy Origin
proxyAuthorization :: Proxy ProxyAuthorization
range :: Proxy Range
referer :: Proxy Referer
tE :: Proxy TE
userAgent :: Proxy UserAgent
xForwardedFor :: Proxy XForwardedFor
xForwardedHost :: Proxy XForwardedHost
xForwardedProto :: Proxy XForwardedProto
xCsrfToken :: Proxy XCsrfToken
accessControlAllowOrigin :: Proxy AccessControlAllowOrigin
accessControlExposeHeaders :: Proxy AccessControlExposeHeaders
accessControlMaxAge :: Proxy AccessControlMaxAge
accessControlAllowCredentials :: Proxy AccessControlAllowCredentials
accessControlAllowMethods :: Proxy AccessControlAllowMethods
accessControlAllowHeaders :: Proxy AccessControlAllowHeaders
acceptPatch :: Proxy AcceptPatch
acceptRanges :: Proxy AcceptRanges
age :: Proxy Age
allow :: Proxy Allow
contentDisposition :: Proxy ContentDisposition
contentEncoding :: Proxy ContentEncoding
contentLanguage :: Proxy ContentLanguage
contentLocation :: Proxy ContentLocation
contentRange :: Proxy ContentRange
contentSecurityPolicy :: Proxy ContentSecurityPolicy
eTag :: Proxy ETag
expires :: Proxy Expires
lastModified :: Proxy LastModified
link :: Proxy Link
location :: Proxy Location
proxyAuthenticate :: Proxy ProxyAuthenticate
publicKeyPins :: Proxy PublicKeyPins
retryAfter :: Proxy RetryAfter
setCookie :: Proxy SetCookie
strictTransportSecurity :: Proxy StrictTransportSecurity
trailer :: Proxy Trailer
transferEncoding :: Proxy TransferEncoding
vary :: Proxy Vary
wWWAuthenticate :: Proxy WWWAuthenticate
instance GHC.TypeLits.KnownSymbol s => Serv.Internal.Header.Name.ReflectName ('Serv.Internal.Header.Name.HeaderName s)
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.CacheControl
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Connection
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.ContentLength
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.ContentType
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Date
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Pragma
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Upgrade
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Via
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Warning
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Accept
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AcceptCharset
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AcceptEncoding
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AcceptLanguage
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AccessControlRequestMethod
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AccessControlRequestHeaders
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Authorization
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Cookie
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Expect
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.From
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Host
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.IfMatch
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.IfModifiedSince
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.IfNoneMatch
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.IfRange
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.IfUnmodifiedSince
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.MaxForwards
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Origin
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.ProxyAuthorization
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Range
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Referer
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.TE
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.UserAgent
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.XForwardedFor
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.XForwardedHost
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.XForwardedProto
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.XCsrfToken
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AccessControlAllowOrigin
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AccessControlExposeHeaders
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AccessControlMaxAge
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AccessControlAllowCredentials
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AccessControlAllowMethods
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AccessControlAllowHeaders
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AcceptPatch
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.AcceptRanges
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Age
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Allow
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.ContentDisposition
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.ContentEncoding
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.ContentLanguage
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.ContentLocation
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.ContentRange
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.ContentSecurityPolicy
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.ETag
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Expires
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.LastModified
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Link
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Location
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.ProxyAuthenticate
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.PublicKeyPins
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.RetryAfter
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.SetCookie
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.StrictTransportSecurity
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Trailer
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.TransferEncoding
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.Vary
instance Serv.Internal.Header.Name.ReflectName 'Serv.Internal.Header.Name.WWWAuthenticate
module Serv.Internal.Header.Serialization
-- | Represents mechanisms to interpret data types as header-compatible
-- values.
--
-- An instance of Encode n t captures a mechanism for treating
-- values of type t as valid data to substantiate the header
-- n.
--
-- Note: While this class allows the encoding of any value into a full
-- Unicode Text value, Headers do not generally accept most Unicode code
-- points. Be conservative in implementing this class.
class ReflectName n => HeaderEncode (n :: HeaderName) a
headerEncode :: HeaderEncode n a => Proxy n -> a -> Maybe Text
-- | Handles encoding a header all the way to raw bytes.
headerEncodeRaw :: HeaderEncode n a => Proxy n -> a -> Maybe ByteString
-- | Represents mechanisms to interpret data types as header-compatible
-- values.
--
-- An instance of Decode n t captures a mechanism for reading
-- values of type t from header data stored at header
-- n.
class ReflectName n => HeaderDecode (n :: HeaderName) a
headerDecode :: HeaderDecode n a => Proxy n -> Maybe Text -> Either String a
headerDecode' :: HeaderDecode n a => Proxy n -> Text -> Either String a
required :: (Text -> Either String a) -> Maybe Text -> Either String a
-- | Handles decoding a header all the way from raw bytes.
headerDecodeRaw :: HeaderDecode n a => Proxy n -> Maybe ByteString -> Either String a
-- | RawText enables capturing the data untouched from the header
headerPair :: HeaderEncode h v => Proxy h -> v -> Maybe Header
instance Serv.Internal.Header.Name.ReflectName n => Serv.Internal.Header.Serialization.HeaderEncode n Serv.Internal.RawText.RawText
instance Serv.Internal.Header.Serialization.HeaderEncode 'Serv.Internal.Header.Name.Allow (Data.Set.Base.Set Serv.Internal.Verb.Verb)
instance Serv.Internal.Header.Serialization.HeaderEncode 'Serv.Internal.Header.Name.Allow [Serv.Internal.Verb.Verb]
instance Serv.Internal.Header.Serialization.HeaderEncode 'Serv.Internal.Header.Name.AccessControlExposeHeaders (Data.Set.Base.Set Network.HTTP.Types.Header.HeaderName)
instance Serv.Internal.Header.Serialization.HeaderEncode 'Serv.Internal.Header.Name.AccessControlAllowHeaders (Data.Set.Base.Set Network.HTTP.Types.Header.HeaderName)
instance Serv.Internal.Header.Serialization.HeaderEncode 'Serv.Internal.Header.Name.AccessControlMaxAge Data.Time.Clock.UTC.NominalDiffTime
instance Serv.Internal.Header.Serialization.HeaderEncode 'Serv.Internal.Header.Name.AccessControlAllowOrigin Data.Text.Internal.Text
instance Serv.Internal.Header.Serialization.HeaderEncode 'Serv.Internal.Header.Name.AccessControlAllowMethods (Data.Set.Base.Set Serv.Internal.Verb.Verb)
instance Serv.Internal.Header.Serialization.HeaderEncode 'Serv.Internal.Header.Name.AccessControlAllowMethods [Serv.Internal.Verb.Verb]
instance Serv.Internal.Header.Serialization.HeaderEncode 'Serv.Internal.Header.Name.AccessControlAllowCredentials GHC.Types.Bool
instance Serv.Internal.Header.Name.ReflectName n => Serv.Internal.Header.Serialization.HeaderEncode n GHC.Types.Bool
instance Serv.Internal.Header.Name.ReflectName n => Serv.Internal.Header.Serialization.HeaderEncode n GHC.Types.Int
instance Serv.Internal.Header.Name.ReflectName n => Serv.Internal.Header.Serialization.HeaderEncode n Data.Text.Internal.Text
instance Serv.Internal.Header.Serialization.HeaderEncode h t => Serv.Internal.Header.Serialization.HeaderEncode h (GHC.Base.Maybe t)
instance Serv.Internal.Header.Name.ReflectName n => Serv.Internal.Header.Serialization.HeaderDecode n Serv.Internal.RawText.RawText
instance Serv.Internal.Header.Serialization.HeaderDecode 'Serv.Internal.Header.Name.Accept [Network.HTTP.Media.Quality.Quality Network.HTTP.Media.MediaType.Internal.MediaType]
instance Serv.Internal.Header.Serialization.HeaderDecode h t => Serv.Internal.Header.Serialization.HeaderDecode h (GHC.Base.Maybe t)
module Serv.Internal.Header
-- | The variant (name and meaning) of a HTTP header.
--
-- An incomplete listing of most permanant headers, a selection of
-- provisional ones, and one or two non-standard headers. Generally, any
-- header desired can be specified using the Name constructor.
--
-- Used only as their DataKinds types system.
data HeaderName
-- | Inject an arbitatry symbol in as a HeaderName. This can be used
-- to implement any sort of custom header
HeaderName :: Symbol -> HeaderName
-- | Used to specify directives that must be obeyed by all caching
-- mechanisms along the request-response chain. Tells all caching
-- mechanisms from server to client whether they may cache this object.
-- It is measured in seconds
--
-- Cache-Control: no-cache
CacheControl :: HeaderName
-- | Control options for the current connection and list of hop-by-hop
-- request fields
--
-- Connection: keep-alive Connection: Upgrade
Connection :: HeaderName
-- | The length of the request body in octets (8-bit bytes)
--
-- Content-Length: 348
ContentLength :: HeaderName
-- | The MIME type of the body of the request (used with POST and PUT
-- requests)
--
-- Content-Type: application/x-www-form-urlencoded
ContentType :: HeaderName
-- | The date and time that the message was sent (in HTTP-date
-- format as defined by RFC 7231 Date/Time Formats)
--
-- Date: Tue, 15 Nov 1994 08:12:31 GMT
Date :: HeaderName
-- | Implementation-specific fields that may have various effects anywhere
-- along the request-response chain.
--
-- Pragma: no-cache
Pragma :: HeaderName
-- | Ask the server to upgrade to another protocol.
--
-- Upgrade: HTTP2.0, SHTTP1.3, IRC6.9, RTAx11
Upgrade :: HeaderName
-- | Informs the server of proxies through which the request was sent.
--
-- Via: 1.0 fred, 1.1 example.com (Apache/1.1)
Via :: HeaderName
-- | A general warning about possible problems with the entity body.
--
-- Warning: 199 Miscellaneous warning
Warning :: HeaderName
-- | Content-Types that are acceptable for the response.
--
-- Accept: text/plain
Accept :: HeaderName
-- | Character sets that are acceptable
--
-- Accept-Charset: utf-8
AcceptCharset :: HeaderName
-- | List of acceptable encodings.
--
-- Accept-Encoding: gzip, deflate
AcceptEncoding :: HeaderName
-- | List of acceptable human languages for response.
--
-- Accept-Language: en-US
AcceptLanguage :: HeaderName
-- | Used when issuing a preflight request to let the server know what HTTP
-- method will be used when the actual request is made.
--
-- Access-Control-Request-Method: POST
AccessControlRequestMethod :: HeaderName
-- | Used when issuing a preflight request to let the server know what HTTP
-- headers will be used when the actual request is made.
--
-- Access-Control-Request-Headers: X-PINGOTHER
AccessControlRequestHeaders :: HeaderName
-- | Authentication credentials for HTTP authentication
--
-- Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Authorization :: HeaderName
-- | An HTTP cookie previously sent by the server with Set-Cookie (below)
--
-- Cookie: $Version=1; Skin=new;
Cookie :: HeaderName
-- | Indicates that particular server behaviors are required by the client
--
-- Expect: 100-continue
Expect :: HeaderName
-- | The email address of the user making the request
--
-- From: user@example.com
From :: HeaderName
-- | The domain name of the server (for virtual hosting), and the TCP port
-- number on which the server is listening. The port number may be
-- omitted if the port is the standard port for the service requested.
--
-- Host: en.wikipedia.org:80 Host: en.wikipedia.org
Host :: HeaderName
-- | Only perform the action if the client supplied entity matches the same
-- entity on the server. This is mainly for methods like PUT to only
-- update a resource if it has not been modified since the user last
-- updated it.
--
-- If-Match: "737060cd8c284d8af7ad3082f209582d"
IfMatch :: HeaderName
-- | Allows a 304 Not Modified to be returned if content is unchanged
--
-- If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
IfModifiedSince :: HeaderName
-- | Allows a 304 Not Modified to be returned if content is unchanged, see
-- HTTP ETag
--
-- If-None-Match: "737060cd8c284d8af7ad3082f209582d"
IfNoneMatch :: HeaderName
-- | If the entity is unchanged, send me the part(s) that I am missing;
-- otherwise, send me the entire new entity
--
-- If-Range: "737060cd8c284d8af7ad3082f209582d"
IfRange :: HeaderName
-- | Only send the response if the entity has not been modified since a
-- specific time.
--
-- If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT
IfUnmodifiedSince :: HeaderName
-- | Limit the number of times the message can be forwarded through proxies
-- or gateways.
--
-- Max-Forwards: 10
MaxForwards :: HeaderName
-- | Initiates a request for cross-origin resource sharing (asks server for
-- an 'Access-Control-Allow-Origin' response field).
--
-- Origin: http://www.example-social-network.com
Origin :: HeaderName
-- | Authorization credentials for connecting to a proxy.
--
-- Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
ProxyAuthorization :: HeaderName
-- | Request only part of an entity. Bytes are numbered from 0.
--
-- Range: bytes=500-999
Range :: HeaderName
-- | This is the address of the previous web page from which a link to the
-- currently requested page was followed. (The word “referrer” has been
-- misspelled in the RFC as well as in most implementations to the point
-- that it has become standard usage and is considered correct
-- terminology)
--
-- Referer: http://en.wikipedia.org/wiki/Main_Page
Referer :: HeaderName
-- | The transfer encodings the user agent is willing to accept: the same
-- values as for the response header field Transfer-Encoding can be used,
-- plus the "trailers" value (related to the "chunked" transfer method)
-- to notify the server it expects to receive additional fields in the
-- trailer after the last, zero-sized, chunk.
--
-- TE: trailers, deflate
TE :: HeaderName
-- | The user agent string of the user agent
--
-- User-Agent: Mozilla5.0 (X11; Linux x86_64; rv:12.0)
-- Gecko20100101 Firefox/21.0
UserAgent :: HeaderName
-- | A de facto standard for identifying the originating IP address of a
-- client connecting to a web server through an HTTP proxy or load
-- balancer
--
-- X-Forwarded-For: client1, proxy1, proxy2 X-Forwarded-For:
-- 129.78.138.66, 129.78.64.103
XForwardedFor :: HeaderName
-- | A de facto standard for identifying the original host requested by the
-- client in the Host HTTP request header, since the host name and/or
-- port of the reverse proxy (load balancer) may differ from the origin
-- server handling the request.
--
-- X-Forwarded-Host: en.wikipedia.org:80 X-Forwarded-Host:
-- en.wikipedia.org
XForwardedHost :: HeaderName
-- | A de facto standard for identifying the originating protocol of an
-- HTTP request, since a reverse proxy (or a load balancer) may
-- communicate with a web server using HTTP even if the request to the
-- reverse proxy is HTTPS.
XForwardedProto :: HeaderName
-- | Used to prevent cross-site request forgery.
--
-- X-Csrf-Token: i8XNjC4b8KVok4uw5RftR38Wgp2BFwql
XCsrfToken :: HeaderName
-- | When responding to a CORS request this lists either an origin or
-- * describing the server's CORS policy for the requested
-- resource
--
-- Access-Control-Allow-Origin: * Access-Control-Allow-Origin:
-- http://foo.example Access-Control-Allow-Origin:
-- https://foo.example
AccessControlAllowOrigin :: HeaderName
-- | This header lets a server whitelist headers that browsers are allowed
-- to access.
--
-- Access-Control-Expose-Headers: X-My-Custom-Header,
-- X-Another-Custom-Header
AccessControlExposeHeaders :: HeaderName
-- | This header indicates how long the results of a preflight request can
-- be cached.
--
-- Access-Control-Max-Age: delta-seconds
AccessControlMaxAge :: HeaderName
-- | Indicates whether or not the response to the request can be exposed
-- when the credentials flag is true. When used as part of a response to
-- a preflight request, this indicates whether or not the actual request
-- can be made using credentials. Note that simple GET requests are not
-- preflighted, and so if a request is made for a resource with
-- credentials, if this header is not returned with the resource, the
-- response is ignored by the browser and not returned to web content.
--
-- Access-Control-Allow-Credentials: true | false
AccessControlAllowCredentials :: HeaderName
-- | Specifies the method or methods allowed when accessing the resource.
-- This is used in response to a preflight request.
--
-- Access-Control-Allow-Methods: method[, method]*
AccessControlAllowMethods :: HeaderName
-- | Used in response to a preflight request to indicate which HTTP headers
-- can be used when making the actual request.
AccessControlAllowHeaders :: HeaderName
-- | Specifies which patch document formats this server supports
--
-- Accept-Patch: text/example;charset=utf-8
AcceptPatch :: HeaderName
-- | What partial content range types this server supports via byte serving
--
-- Accept-Ranges: bytes
AcceptRanges :: HeaderName
-- | The age the object has been in a proxy cache in seconds
--
-- Age: 12
Age :: HeaderName
-- | Valid actions for a specified resource. To be used for a 405 Method
-- not allowed
--
-- Allow: GET, HEAD
Allow :: HeaderName
-- | An opportunity to raise a "File Download" dialogue box for a known
-- MIME type with binary format or suggest a filename for dynamic
-- content. Quotes are necessary with special characters.
--
-- Content-Disposition: attachment; filename="fname.ext"
ContentDisposition :: HeaderName
-- | The type of encoding used on the data.
--
-- Content-Encoding: gzip
ContentEncoding :: HeaderName
-- | The natural language or languages of the intended audience for the
-- enclosed content
--
-- Content-Language: da
ContentLanguage :: HeaderName
-- | An alternate location for the returned data
--
-- Content-Location: /index.htm
ContentLocation :: HeaderName
-- | Where in a full body message this partial message belongs
--
-- Content-Range: bytes 21010-47021/47022
ContentRange :: HeaderName
-- | Content Security Policy definition.
--
-- Content-Security-Policy: default-src self
ContentSecurityPolicy :: HeaderName
-- | An identifier for a specific version of a resource, often a message
-- digest
--
-- ETag: "737060cd8c284d8af7ad3082f209582d"
ETag :: HeaderName
-- | Gives the date/time after which the response is considered stale (in
-- HTTP-date format as defined by RFC 7231)
--
-- Expires: Thu, 01 Dec 1994 16:00:00 GMT
Expires :: HeaderName
-- | The last modified date for the requested object (in HTTP-date
-- format as defined by RFC 7231)
--
-- Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
LastModified :: HeaderName
-- | Used to express a typed relationship with another resource, where the
-- relation type is defined by RFC 5988
--
-- Link: /feed; rel="alternate"
Link :: HeaderName
-- | Used in redirection, or when a new resource has been created.
--
-- Location: http://www.w3.org/pub/WWW/People.html
Location :: HeaderName
-- | Request authentication to access the proxy.
--
-- Proxy-Authenticate: Basic
ProxyAuthenticate :: HeaderName
-- | HTTP Public Key Pinning, announces hash of website's authentic TLS
-- certificate
--
-- Public-Key-Pins: max-age=2592000;
-- pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
PublicKeyPins :: HeaderName
-- | If an entity is temporarily unavailable, this instructs the client to
-- try again later. Value could be a specified period of time (in
-- seconds) or a HTTP-date.
--
-- Retry-After: 120 Retry-After: Fri, 07 Nov 2014 23:59:59 GMT
RetryAfter :: HeaderName
-- | An HTTP cookie
--
-- Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1
SetCookie :: HeaderName
-- | A HSTS Policy informing the HTTP client how long to cache the HTTPS
-- only policy and whether this applies to subdomains.
--
-- Strict-Transport-Security: max-age=16070400; includeSubDomains
StrictTransportSecurity :: HeaderName
-- | The Trailer general field value indicates that the given set of header
-- fields is present in the trailer of a message encoded with chunked
-- transfer coding.
--
-- Trailer: Max-Forwards
Trailer :: HeaderName
-- | The form of encoding used to safely transfer the entity to the user.
-- Currently defined methods are: chunked, compress, deflate, gzip,
-- identity.
--
-- Transfer-Encoding: chunked
TransferEncoding :: HeaderName
-- | Tells downstream proxies how to match future request headers to decide
-- whether the cached response can be used rather than requesting a fresh
-- one from the origin server.
--
-- Vary: * Vary: Accept-Language
Vary :: HeaderName
-- | Indicates the authentication scheme that should be used to access the
-- requested entity.
--
-- WWW-Authenticate: Basic
WWWAuthenticate :: HeaderName
reflectName :: ReflectName n => proxy n -> HeaderName
-- | Implements reflection of Name types into HeaderName
-- values for runtime use.
class ReflectName (n :: HeaderName)
reflectName :: ReflectName n => proxy n -> HeaderName
-- | Given a record of headers, encode them into a list of header pairs.
class ReflectHeaders headers
reflectHeaders :: ReflectHeaders headers => Rec headers -> [Header]
-- | Given a header set description, reflect out all of the names
class ReflectHeaderNames headers
reflectHeaderNames :: ReflectHeaderNames headers => Proxy headers -> [HeaderName]
-- | Represents mechanisms to interpret data types as header-compatible
-- values.
--
-- An instance of Encode n t captures a mechanism for treating
-- values of type t as valid data to substantiate the header
-- n.
--
-- Note: While this class allows the encoding of any value into a full
-- Unicode Text value, Headers do not generally accept most Unicode code
-- points. Be conservative in implementing this class.
class ReflectName n => HeaderEncode (n :: HeaderName) a
headerEncode :: HeaderEncode n a => Proxy n -> a -> Maybe Text
-- | Handles encoding a header all the way to raw bytes.
headerEncodeRaw :: HeaderEncode n a => Proxy n -> a -> Maybe ByteString
headerPair :: HeaderEncode h v => Proxy h -> v -> Maybe Header
-- | Represents mechanisms to interpret data types as header-compatible
-- values.
--
-- An instance of Decode n t captures a mechanism for reading
-- values of type t from header data stored at header
-- n.
class ReflectName n => HeaderDecode (n :: HeaderName) a
headerDecode :: HeaderDecode n a => Proxy n -> Maybe Text -> Either String a
-- | Handles decoding a header all the way from raw bytes.
headerDecodeRaw :: HeaderDecode n a => Proxy n -> Maybe ByteString -> Either String a
instance Serv.Internal.Header.ReflectHeaderNames '[]
instance forall b (name :: Serv.Internal.Header.Name.HeaderName) (hdrs :: [Serv.Internal.Pair.Pair Serv.Internal.Header.Name.HeaderName b]) (ty :: b). (Serv.Internal.Header.Name.ReflectName name, Serv.Internal.Header.ReflectHeaderNames hdrs) => Serv.Internal.Header.ReflectHeaderNames (name 'Serv.Internal.Pair.::: ty : hdrs)
instance Serv.Internal.Header.ReflectHeaders '[]
instance (Serv.Internal.Header.Name.ReflectName name, Serv.Internal.Header.Serialization.HeaderEncode name ty, Serv.Internal.Header.ReflectHeaders headers) => Serv.Internal.Header.ReflectHeaders (name 'Serv.Internal.Pair.::: ty : headers)
-- | Types, but really kinds, which represent the structure of an API.
module Serv.Internal.Api
-- | 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. OneOf choices expresses this sequential
-- search along a set of sub-Api 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.
data Api star
[Endpoint] :: [Method star] -> Api star
[OneOf] :: [Api star] -> Api star
[Raw] :: Api star
[:>] :: Path star -> Api star -> Api star
-- | 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.
data Method star
[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
-- | 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
data Body star
[Body] :: [star] -> star -> Body star
[Empty] :: Body star
-- | 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.
data Path star
[Const] :: Symbol -> Path star
[HeaderAs] :: HeaderName -> Symbol -> Path star
[Seg] :: Symbol -> star -> Path star
[Header] :: HeaderName -> star -> Path star
[Wildcard] :: Path star
[Flag] :: Symbol -> Path star
[QueryParam] :: Symbol -> star -> Path star
[Cors] :: star -> Path star
-- | Typeclasses constructing functions which reflect and analyze API
-- types.
module Serv.Internal.Api.Analysis
class VerbsOf methods
verbsOf :: VerbsOf methods => Proxy methods -> Set Verb
class HeadersExpectedOf (methods :: [Method *])
headersExpectedOf :: HeadersExpectedOf methods => Proxy methods -> Set HeaderName
class HeadersReturnedBy (methods :: [Method *])
headersReturnedBy :: HeadersReturnedBy methods => Proxy methods -> Set HeaderName
instance Serv.Internal.Api.Analysis.VerbsOf '[]
instance forall star (verb :: Serv.Internal.Verb.Verb) (methods :: [Serv.Internal.Api.Method star]) (headers :: [Serv.Internal.Pair.Pair Serv.Internal.Header.Name.HeaderName star]) (body :: Serv.Internal.Api.Body star). (Serv.Internal.Verb.ReflectVerb verb, Serv.Internal.Api.Analysis.VerbsOf methods) => Serv.Internal.Api.Analysis.VerbsOf ('Serv.Internal.Api.Method verb headers body : methods)
instance Serv.Internal.Api.Analysis.HeadersExpectedOf '[]
instance Serv.Internal.Api.Analysis.HeadersExpectedOf rs => Serv.Internal.Api.Analysis.HeadersExpectedOf ('Serv.Internal.Api.Method verb headers body : rs)
instance (Serv.Internal.Api.Analysis.HeadersExpectedOf (method : rs), Serv.Internal.Header.ReflectHeaderNames hdrs) => Serv.Internal.Api.Analysis.HeadersExpectedOf ('Serv.Internal.Api.CaptureHeaders hdrs method : rs)
instance Serv.Internal.Api.Analysis.HeadersExpectedOf (method : rs) => Serv.Internal.Api.Analysis.HeadersExpectedOf ('Serv.Internal.Api.CaptureBody ctypes ty method : rs)
instance Serv.Internal.Api.Analysis.HeadersExpectedOf (method : rs) => Serv.Internal.Api.Analysis.HeadersExpectedOf ('Serv.Internal.Api.CaptureQuery names method : rs)
instance Serv.Internal.Api.Analysis.HeadersReturnedBy '[]
instance (Serv.Internal.Header.ReflectHeaderNames headers, Serv.Internal.Api.Analysis.HeadersReturnedBy rs) => Serv.Internal.Api.Analysis.HeadersReturnedBy ('Serv.Internal.Api.Method verb headers body : rs)
instance Serv.Internal.Api.Analysis.HeadersReturnedBy (method : rs) => Serv.Internal.Api.Analysis.HeadersReturnedBy ('Serv.Internal.Api.CaptureHeaders hdrs method : rs)
instance Serv.Internal.Api.Analysis.HeadersReturnedBy (method : rs) => Serv.Internal.Api.Analysis.HeadersReturnedBy ('Serv.Internal.Api.CaptureBody ctypes ty method : rs)
instance Serv.Internal.Api.Analysis.HeadersReturnedBy (method : rs) => Serv.Internal.Api.Analysis.HeadersReturnedBy ('Serv.Internal.Api.CaptureQuery names method : rs)
module Serv.Header.Proxies
-- | A concrete, poly-kinded proxy type
data Proxy k (t :: k) :: forall k. k -> *
Proxy :: Proxy k
cacheControl :: Proxy CacheControl
connection :: Proxy Connection
contentLength :: Proxy ContentLength
contentType :: Proxy ContentType
date :: Proxy Date
pragma :: Proxy Pragma
upgrade :: Proxy Upgrade
via :: Proxy Via
warning :: Proxy Warning
accept :: Proxy Accept
acceptCharset :: Proxy AcceptCharset
acceptEncoding :: Proxy AcceptEncoding
acceptLanguage :: Proxy AcceptLanguage
accessControlRequestMethod :: Proxy AccessControlRequestMethod
accessControlRequestHeaders :: Proxy AccessControlRequestHeaders
authorization :: Proxy Authorization
cookie :: Proxy Cookie
expect :: Proxy Expect
from :: Proxy From
host :: Proxy Host
ifMatch :: Proxy IfMatch
ifModifiedSince :: Proxy IfModifiedSince
ifNoneMatch :: Proxy IfNoneMatch
ifRange :: Proxy IfRange
ifUnmodifiedSince :: Proxy IfUnmodifiedSince
maxForwards :: Proxy MaxForwards
origin :: Proxy Origin
proxyAuthorization :: Proxy ProxyAuthorization
range :: Proxy Range
referer :: Proxy Referer
tE :: Proxy TE
userAgent :: Proxy UserAgent
xForwardedFor :: Proxy XForwardedFor
xForwardedHost :: Proxy XForwardedHost
xForwardedProto :: Proxy XForwardedProto
xCsrfToken :: Proxy XCsrfToken
accessControlAllowOrigin :: Proxy AccessControlAllowOrigin
accessControlExposeHeaders :: Proxy AccessControlExposeHeaders
accessControlMaxAge :: Proxy AccessControlMaxAge
accessControlAllowCredentials :: Proxy AccessControlAllowCredentials
accessControlAllowMethods :: Proxy AccessControlAllowMethods
accessControlAllowHeaders :: Proxy AccessControlAllowHeaders
acceptPatch :: Proxy AcceptPatch
acceptRanges :: Proxy AcceptRanges
age :: Proxy Age
allow :: Proxy Allow
contentDisposition :: Proxy ContentDisposition
contentEncoding :: Proxy ContentEncoding
contentLanguage :: Proxy ContentLanguage
contentLocation :: Proxy ContentLocation
contentRange :: Proxy ContentRange
contentSecurityPolicy :: Proxy ContentSecurityPolicy
eTag :: Proxy ETag
expires :: Proxy Expires
lastModified :: Proxy LastModified
link :: Proxy Link
location :: Proxy Location
proxyAuthenticate :: Proxy ProxyAuthenticate
publicKeyPins :: Proxy PublicKeyPins
retryAfter :: Proxy RetryAfter
setCookie :: Proxy SetCookie
strictTransportSecurity :: Proxy StrictTransportSecurity
trailer :: Proxy Trailer
transferEncoding :: Proxy TransferEncoding
vary :: Proxy Vary
wWWAuthenticate :: Proxy WWWAuthenticate
module Serv.Internal.Cors
-- | A CorsPolicy interprets the request's provided Origin and the
-- current routing context to determine how to expose resources to the
-- requestor.
type Policy = Config -> Context -> AccessSet
-- | Class describing types which describe CORS Policys.
class CorsPolicy m
corsPolicy :: CorsPolicy m => Proxy m -> Policy
-- | The PermitAll policy produces the permitAll
-- Policy.
data PermitAll
headerSet :: Bool -> Context -> AccessSet -> [Header]
-- | The CorsContext provides data from which we can make choices
-- about how to respond to CORS requests.
data Context
Context :: Text -> Set HeaderName -> Set HeaderName -> Set Verb -> Context
[origin] :: Context -> Text
[headersExpected] :: Context -> Set HeaderName
[headersReturned] :: Context -> Set HeaderName
[methodsAvailable] :: Context -> Set Verb
mergeContext :: Context -> Context -> Context
-- | Descrbes what parts of the response should be made available
-- cross-origin. The Monoid product on AccessSets permits all
-- accesses of either of the constituents.
data AccessSet
AccessSet :: Bool -> Set HeaderName -> Bool -> Set Verb -> Set HeaderName -> Maybe NominalDiffTime -> AccessSet
[originAllowed] :: AccessSet -> Bool
[headersExposed] :: AccessSet -> Set HeaderName
[credentialsAllowed] :: AccessSet -> Bool
[methodsAllowed] :: AccessSet -> Set Verb
[headersAllowed] :: AccessSet -> Set HeaderName
[maxAge] :: AccessSet -> Maybe NominalDiffTime
-- | The empty access set disallows all CORS access while the product l
-- <> r provides access to a particular part of the response
-- if either l or r does.
-- | The most permissive CORS Policy possible. Differs from Wildcard
-- in that it allows credentials. Max age is not provided (so no caching)
permitAll :: Policy
-- | Effects a wildcard policy which provides maximal cross-origin access
-- to all request origins. This disallows credentials use, however.
wildcard :: Policy
-- | Provides access to all origins which pass a predicate
predicateWhitelist :: (Text -> Bool) -> Policy
instance Serv.Internal.Cors.CorsPolicy Serv.Internal.Cors.PermitAll
instance GHC.Base.Monoid Serv.Internal.Cors.AccessSet
module Serv.Internal.Server.Context
data Context
Context :: Request -> ([Text], [Text]) -> [(HeaderName, Maybe Text)] -> Config -> ByteString -> [Policy] -> Context
[request] :: Context -> Request
[pathZipper] :: Context -> ([Text], [Text])
[headersExpected] :: Context -> [(HeaderName, Maybe Text)]
[config] :: Context -> Config
[body] :: Context -> ByteString
[corsPolicies] :: Context -> [Policy]
corsHeaders :: (HeadersExpectedOf methods, HeadersReturnedBy methods, VerbsOf methods) => Proxy methods -> Bool -> Context -> Maybe [Header]
makeContext :: Config -> Request -> IO Context
pathIsEmpty :: Context -> Bool
method :: Context -> Method
requestHeadersSeen :: Context -> Set HeaderName
-- | Pop all remaining segments off the context
takeAllSegments :: Context -> (Context, [Text])
-- | Pop a segment off the URI and produce a new context for "beyond" that
-- segment
takeSegment :: Context -> (Context, Maybe Text)
-- | Move the context down the URI segment listing one step if possible.
stepContext :: Context -> Context
-- | Pull a Header raw from the context, updating it to note that we looked
pullHeaderRaw :: HeaderName -> Context -> (Context, Maybe ByteString)
-- | Pull a header value from the context, updating it to note that we
-- looked
examineHeader :: HeaderDecode n a => Proxy n -> Context -> (Context, Either String a)
-- | Sort of like examineHeader but used for when we just want the
-- value and don't care about updating the context or worrying about
-- distinguishing between decoding failure and outright not being there
-- at all!
examineHeaderFast :: HeaderDecode n a => Proxy n -> Context -> Maybe a
-- | Match a header value in the context, updating it to show that we
-- looked
expectHeader :: ReflectName n => Proxy n -> Text -> Context -> (Context, Bool)
safeHead :: [a] -> Maybe a
module Serv.Internal.Server.Type
-- | A server implementation which always results in a "Not Found" error.
-- Used to give semantics to "pathological" servers like 'OneOf
-- '[] and Endpoint '[].
--
-- These servers could be statically disallowed but (1) they have a
-- semantic sense as described by this type exactly and (2) to do so
-- would require the creation and management of either larger types or
-- non-empty proofs which would be burdensome to carry about.
data NotHere
NotHere :: NotHere
-- | Actual servers are implemented effectfully; this is a no-op server
-- which immediately returns Not Found and applies no effects.
noOp :: Applicative m => m NotHere
-- | Either one thing or the other. In particular, often this is used when
-- we are describing either one server implementation or the other. Used
-- to give semantics to 'OneOf and 'Endpoint.
data (:<|>) a b
(:<|>) :: a -> b -> (:<|>) a b
-- | A return value from a Server computation.
data ServerValue
-- | Routing errors arise when a routing attempt fails and, depending on
-- the error, either we should recover and backtrack or resolve the
-- entire response with that error.
RoutingError :: RoutingError -> ServerValue
-- | If the response is arising from the Server computation itself
-- it will be transformed automatically into a Response value we
-- can handle directly. These are opaque to routing, assumed successes.
WaiResponse :: Response -> ServerValue
-- | If the application demands an "upgrade" or ties into another server
-- mechanism then routing at that location will return the (opaque)
-- Application to continue handling.
Application :: Application -> ServerValue
runServerWai :: Context -> (Response -> IO ResponseReceived) -> (Server IO -> IO ResponseReceived)
newtype Server m
Server :: (Context -> m ServerValue) -> Server m
[runServer] :: Server m -> Context -> m ServerValue
transformServer :: (forall x. m x -> n x) -> Server m -> Server n
-- | Servers form a semigroup trying each Server in order and
-- receiving the leftmost one which does not end in an ignorable error.
--
-- Or, with less technical jargon, m orElse n acts like
-- m except in the case where m returns an
-- ignorable Error in which case control flows on to
-- n.
orElse :: Monad m => Server m -> Server m -> Server m
routingError :: Monad m => RoutingError -> m ServerValue
-- | Responses generated in Server implementations.
data Response (headers :: [Pair HeaderName *]) body
[Response] :: Status -> [Header] -> Rec headers -> a -> Response headers (Body ctypes a)
[EmptyResponse] :: Status -> [Header] -> Rec headers -> Response headers Empty
emptyResponse :: Status -> Response '[] Empty
-- | Adds a body to a response
withBody :: a -> Response headers Empty -> Response headers (Body ctypes a)
-- | Adds a header to a response
withHeader :: Proxy name -> value -> Response headers body -> Response ((name ::: value) : headers) body
-- | Unlike withHeader, withQuietHeader allows you to add
-- headers not explicitly specified in the api specification.
withQuietHeader :: HeaderEncode name value => Proxy name -> value -> Response headers body -> Response headers body
-- | If a response type is complete defined by its implementation then
-- applying resorted to it will future proof it against
-- reorderings of headers. If the response type is not completely
-- inferrable, however, then this will require manual annotations of the
-- "pre-sorted" response.
resortHeaders :: RecordIso headers headers' => Response headers body -> Response headers' body
-- | Used primarily for implementing HEAD request automatically.
deleteBody :: Response headers body -> Response headers Empty
class ReflectHeaders headers => WaiResponse headers body
waiResponse :: WaiResponse headers body => [Quality MediaType] -> Response headers body -> Response
instance Serv.Internal.Header.ReflectHeaders headers => Serv.Internal.Server.Type.WaiResponse headers 'Serv.Internal.Api.Empty
instance (Serv.Internal.Header.ReflectHeaders headers, Serv.Internal.MediaType.ReflectEncoders ctypes a) => Serv.Internal.Server.Type.WaiResponse headers ('Serv.Internal.Api.Body ctypes a)
module Serv.Internal.Server
-- | The the core type function responsible for interpreting an Api
-- into a functioning Server. It defines a function handle
-- defined over all forms of Api types which consumes a parallel
-- type defined by the associated type family Impl. If api ::
-- Api then Impl api m is an "implementation" of the
-- Api's server logic executing in the m monad. Then,
-- applying handle to a value of Impl api results
-- in a Server which can be executed as a Application.
class Handling (spec :: k) where type Impl spec (m :: * -> *) where {
type family Impl spec (m :: * -> *);
}
handle :: (Handling spec, Monad m) => Proxy spec -> Impl spec m -> Server m
encodeBody :: WaiResponse hdrs body => Context -> Response hdrs body -> ServerValue
-- | GET is special-cased to handle HEAD semantics which
-- cannot be specified otherwise.
-- | Is the request method in the set of verbs?
verbMatch :: Set Verb -> Method -> Bool
defaultOptionsResponse :: Set Verb -> ServerValue
instance Serv.Internal.Server.Type.WaiResponse headers body => Serv.Internal.Server.Handling ('Serv.Internal.Api.Method 'Serv.Internal.Verb.GET headers body)
instance (Serv.Internal.Verb.ReflectVerb verb, Serv.Internal.Server.Type.WaiResponse headers body) => Serv.Internal.Server.Handling ('Serv.Internal.Api.Method verb headers body)
instance Serv.Internal.Server.Handling method => Serv.Internal.Server.Handling ('Serv.Internal.Api.CaptureHeaders headers method)
instance Serv.Internal.Server.Handling method => Serv.Internal.Server.Handling ('Serv.Internal.Api.CaptureQuery query method)
instance Serv.Internal.Server.Handling method => Serv.Internal.Server.Handling ('Serv.Internal.Api.CaptureBody ctypes value method)
instance Serv.Internal.Server.Handling 'Serv.Internal.Api.Raw
instance (Serv.Internal.Api.Analysis.VerbsOf methods, Serv.Internal.Api.Analysis.HeadersReturnedBy methods, Serv.Internal.Api.Analysis.HeadersExpectedOf methods, Serv.Internal.Server.Handling methods) => Serv.Internal.Server.Handling ('Serv.Internal.Api.Endpoint methods)
instance Serv.Internal.Server.Handling '[]
instance forall a (x :: a) (xs :: [a]). (Serv.Internal.Server.Handling x, Serv.Internal.Server.Handling xs) => Serv.Internal.Server.Handling (x : xs)
instance forall star (apis :: [Serv.Internal.Api.Api star]). Serv.Internal.Server.Handling apis => Serv.Internal.Server.Handling ('Serv.Internal.Api.OneOf apis)
instance forall star (s :: GHC.Types.Symbol) (api :: Serv.Internal.Api.Api star). (GHC.TypeLits.KnownSymbol s, Serv.Internal.Server.Handling api) => Serv.Internal.Server.Handling ('Serv.Internal.Api.Const s 'Serv.Internal.Api.:> api)
instance forall star (api :: Serv.Internal.Api.Api star). Serv.Internal.Server.Handling api => Serv.Internal.Server.Handling ('Serv.Internal.Api.Wildcard 'Serv.Internal.Api.:> api)
instance forall star (n :: Serv.Internal.Header.Name.HeaderName) (v :: GHC.Types.Symbol) (api :: Serv.Internal.Api.Api star). (Serv.Internal.Header.Name.ReflectName n, GHC.TypeLits.KnownSymbol v, Serv.Internal.Server.Handling api) => Serv.Internal.Server.Handling ('Serv.Internal.Api.HeaderAs n v 'Serv.Internal.Api.:> api)
instance (Serv.Internal.Header.Serialization.HeaderDecode n v, Serv.Internal.Server.Handling api) => Serv.Internal.Server.Handling ('Serv.Internal.Api.Header n v 'Serv.Internal.Api.:> api)
instance (Serv.Internal.URI.URIDecode v, Serv.Internal.Server.Handling api) => Serv.Internal.Server.Handling ('Serv.Internal.Api.Seg n v 'Serv.Internal.Api.:> api)
instance (Serv.Internal.Server.Handling api, Serv.Internal.Cors.CorsPolicy p) => Serv.Internal.Server.Handling ('Serv.Internal.Api.Cors p 'Serv.Internal.Api.:> api)
module Serv.Server
data Server m
transformServer :: (forall x. m x -> n x) -> Server m -> Server n
-- | Build a Application from an implemented Server
-- IO.
makeApplication :: Config -> Server IO -> Application
data Config
defaultConfig :: Config
-- | The the core type function responsible for interpreting an Api
-- into a functioning Server. It defines a function handle
-- defined over all forms of Api types which consumes a parallel
-- type defined by the associated type family Impl. If api ::
-- Api then Impl api m is an "implementation" of the
-- Api's server logic executing in the m monad. Then,
-- applying handle to a value of Impl api results
-- in a Server which can be executed as a Application.
class Handling (spec :: k) where type Impl spec (m :: * -> *) where {
type family Impl spec (m :: * -> *);
}
handle :: (Handling spec, Monad m) => Proxy spec -> Impl spec m -> Server m
-- | Either one thing or the other. In particular, often this is used when
-- we are describing either one server implementation or the other. Used
-- to give semantics to 'OneOf and 'Endpoint.
data (:<|>) a b
(:<|>) :: a -> b -> (:<|>) a b
-- | A server implementation which always results in a "Not Found" error.
-- Used to give semantics to "pathological" servers like 'OneOf
-- '[] and Endpoint '[].
--
-- These servers could be statically disallowed but (1) they have a
-- semantic sense as described by this type exactly and (2) to do so
-- would require the creation and management of either larger types or
-- non-empty proofs which would be burdensome to carry about.
data NotHere
NotHere :: NotHere
-- | Actual servers are implemented effectfully; this is a no-op server
-- which immediately returns Not Found and applies no effects.
noOp :: Applicative m => m NotHere
-- | Responses generated in Server implementations.
data Response (headers :: [Pair HeaderName *]) body
emptyResponse :: Status -> Response '[] Empty
-- | Adds a body to a response
withBody :: a -> Response headers Empty -> Response headers (Body ctypes a)
-- | Adds a header to a response
withHeader :: Proxy name -> value -> Response headers body -> Response ((name ::: value) : headers) body
-- | Unlike withHeader, withQuietHeader allows you to add
-- headers not explicitly specified in the api specification.
withQuietHeader :: HeaderEncode name value => Proxy name -> value -> Response headers body -> Response headers body
module Serv.Header
-- | The variant (name and meaning) of a HTTP header.
--
-- An incomplete listing of most permanant headers, a selection of
-- provisional ones, and one or two non-standard headers. Generally, any
-- header desired can be specified using the Name constructor.
--
-- Used only as their DataKinds types system.
data HeaderName
-- | Inject an arbitatry symbol in as a HeaderName. This can be used
-- to implement any sort of custom header
HeaderName :: Symbol -> HeaderName
-- | Used to specify directives that must be obeyed by all caching
-- mechanisms along the request-response chain. Tells all caching
-- mechanisms from server to client whether they may cache this object.
-- It is measured in seconds
--
-- Cache-Control: no-cache
CacheControl :: HeaderName
-- | Control options for the current connection and list of hop-by-hop
-- request fields
--
-- Connection: keep-alive Connection: Upgrade
Connection :: HeaderName
-- | The length of the request body in octets (8-bit bytes)
--
-- Content-Length: 348
ContentLength :: HeaderName
-- | The MIME type of the body of the request (used with POST and PUT
-- requests)
--
-- Content-Type: application/x-www-form-urlencoded
ContentType :: HeaderName
-- | The date and time that the message was sent (in HTTP-date
-- format as defined by RFC 7231 Date/Time Formats)
--
-- Date: Tue, 15 Nov 1994 08:12:31 GMT
Date :: HeaderName
-- | Implementation-specific fields that may have various effects anywhere
-- along the request-response chain.
--
-- Pragma: no-cache
Pragma :: HeaderName
-- | Ask the server to upgrade to another protocol.
--
-- Upgrade: HTTP2.0, SHTTP1.3, IRC6.9, RTAx11
Upgrade :: HeaderName
-- | Informs the server of proxies through which the request was sent.
--
-- Via: 1.0 fred, 1.1 example.com (Apache/1.1)
Via :: HeaderName
-- | A general warning about possible problems with the entity body.
--
-- Warning: 199 Miscellaneous warning
Warning :: HeaderName
-- | Content-Types that are acceptable for the response.
--
-- Accept: text/plain
Accept :: HeaderName
-- | Character sets that are acceptable
--
-- Accept-Charset: utf-8
AcceptCharset :: HeaderName
-- | List of acceptable encodings.
--
-- Accept-Encoding: gzip, deflate
AcceptEncoding :: HeaderName
-- | List of acceptable human languages for response.
--
-- Accept-Language: en-US
AcceptLanguage :: HeaderName
-- | Used when issuing a preflight request to let the server know what HTTP
-- method will be used when the actual request is made.
--
-- Access-Control-Request-Method: POST
AccessControlRequestMethod :: HeaderName
-- | Used when issuing a preflight request to let the server know what HTTP
-- headers will be used when the actual request is made.
--
-- Access-Control-Request-Headers: X-PINGOTHER
AccessControlRequestHeaders :: HeaderName
-- | Authentication credentials for HTTP authentication
--
-- Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Authorization :: HeaderName
-- | An HTTP cookie previously sent by the server with Set-Cookie (below)
--
-- Cookie: $Version=1; Skin=new;
Cookie :: HeaderName
-- | Indicates that particular server behaviors are required by the client
--
-- Expect: 100-continue
Expect :: HeaderName
-- | The email address of the user making the request
--
-- From: user@example.com
From :: HeaderName
-- | The domain name of the server (for virtual hosting), and the TCP port
-- number on which the server is listening. The port number may be
-- omitted if the port is the standard port for the service requested.
--
-- Host: en.wikipedia.org:80 Host: en.wikipedia.org
Host :: HeaderName
-- | Only perform the action if the client supplied entity matches the same
-- entity on the server. This is mainly for methods like PUT to only
-- update a resource if it has not been modified since the user last
-- updated it.
--
-- If-Match: "737060cd8c284d8af7ad3082f209582d"
IfMatch :: HeaderName
-- | Allows a 304 Not Modified to be returned if content is unchanged
--
-- If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
IfModifiedSince :: HeaderName
-- | Allows a 304 Not Modified to be returned if content is unchanged, see
-- HTTP ETag
--
-- If-None-Match: "737060cd8c284d8af7ad3082f209582d"
IfNoneMatch :: HeaderName
-- | If the entity is unchanged, send me the part(s) that I am missing;
-- otherwise, send me the entire new entity
--
-- If-Range: "737060cd8c284d8af7ad3082f209582d"
IfRange :: HeaderName
-- | Only send the response if the entity has not been modified since a
-- specific time.
--
-- If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT
IfUnmodifiedSince :: HeaderName
-- | Limit the number of times the message can be forwarded through proxies
-- or gateways.
--
-- Max-Forwards: 10
MaxForwards :: HeaderName
-- | Initiates a request for cross-origin resource sharing (asks server for
-- an 'Access-Control-Allow-Origin' response field).
--
-- Origin: http://www.example-social-network.com
Origin :: HeaderName
-- | Authorization credentials for connecting to a proxy.
--
-- Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
ProxyAuthorization :: HeaderName
-- | Request only part of an entity. Bytes are numbered from 0.
--
-- Range: bytes=500-999
Range :: HeaderName
-- | This is the address of the previous web page from which a link to the
-- currently requested page was followed. (The word “referrer” has been
-- misspelled in the RFC as well as in most implementations to the point
-- that it has become standard usage and is considered correct
-- terminology)
--
-- Referer: http://en.wikipedia.org/wiki/Main_Page
Referer :: HeaderName
-- | The transfer encodings the user agent is willing to accept: the same
-- values as for the response header field Transfer-Encoding can be used,
-- plus the "trailers" value (related to the "chunked" transfer method)
-- to notify the server it expects to receive additional fields in the
-- trailer after the last, zero-sized, chunk.
--
-- TE: trailers, deflate
TE :: HeaderName
-- | The user agent string of the user agent
--
-- User-Agent: Mozilla5.0 (X11; Linux x86_64; rv:12.0)
-- Gecko20100101 Firefox/21.0
UserAgent :: HeaderName
-- | A de facto standard for identifying the originating IP address of a
-- client connecting to a web server through an HTTP proxy or load
-- balancer
--
-- X-Forwarded-For: client1, proxy1, proxy2 X-Forwarded-For:
-- 129.78.138.66, 129.78.64.103
XForwardedFor :: HeaderName
-- | A de facto standard for identifying the original host requested by the
-- client in the Host HTTP request header, since the host name and/or
-- port of the reverse proxy (load balancer) may differ from the origin
-- server handling the request.
--
-- X-Forwarded-Host: en.wikipedia.org:80 X-Forwarded-Host:
-- en.wikipedia.org
XForwardedHost :: HeaderName
-- | A de facto standard for identifying the originating protocol of an
-- HTTP request, since a reverse proxy (or a load balancer) may
-- communicate with a web server using HTTP even if the request to the
-- reverse proxy is HTTPS.
XForwardedProto :: HeaderName
-- | Used to prevent cross-site request forgery.
--
-- X-Csrf-Token: i8XNjC4b8KVok4uw5RftR38Wgp2BFwql
XCsrfToken :: HeaderName
-- | When responding to a CORS request this lists either an origin or
-- * describing the server's CORS policy for the requested
-- resource
--
-- Access-Control-Allow-Origin: * Access-Control-Allow-Origin:
-- http://foo.example Access-Control-Allow-Origin:
-- https://foo.example
AccessControlAllowOrigin :: HeaderName
-- | This header lets a server whitelist headers that browsers are allowed
-- to access.
--
-- Access-Control-Expose-Headers: X-My-Custom-Header,
-- X-Another-Custom-Header
AccessControlExposeHeaders :: HeaderName
-- | This header indicates how long the results of a preflight request can
-- be cached.
--
-- Access-Control-Max-Age: delta-seconds
AccessControlMaxAge :: HeaderName
-- | Indicates whether or not the response to the request can be exposed
-- when the credentials flag is true. When used as part of a response to
-- a preflight request, this indicates whether or not the actual request
-- can be made using credentials. Note that simple GET requests are not
-- preflighted, and so if a request is made for a resource with
-- credentials, if this header is not returned with the resource, the
-- response is ignored by the browser and not returned to web content.
--
-- Access-Control-Allow-Credentials: true | false
AccessControlAllowCredentials :: HeaderName
-- | Specifies the method or methods allowed when accessing the resource.
-- This is used in response to a preflight request.
--
-- Access-Control-Allow-Methods: method[, method]*
AccessControlAllowMethods :: HeaderName
-- | Used in response to a preflight request to indicate which HTTP headers
-- can be used when making the actual request.
AccessControlAllowHeaders :: HeaderName
-- | Specifies which patch document formats this server supports
--
-- Accept-Patch: text/example;charset=utf-8
AcceptPatch :: HeaderName
-- | What partial content range types this server supports via byte serving
--
-- Accept-Ranges: bytes
AcceptRanges :: HeaderName
-- | The age the object has been in a proxy cache in seconds
--
-- Age: 12
Age :: HeaderName
-- | Valid actions for a specified resource. To be used for a 405 Method
-- not allowed
--
-- Allow: GET, HEAD
Allow :: HeaderName
-- | An opportunity to raise a "File Download" dialogue box for a known
-- MIME type with binary format or suggest a filename for dynamic
-- content. Quotes are necessary with special characters.
--
-- Content-Disposition: attachment; filename="fname.ext"
ContentDisposition :: HeaderName
-- | The type of encoding used on the data.
--
-- Content-Encoding: gzip
ContentEncoding :: HeaderName
-- | The natural language or languages of the intended audience for the
-- enclosed content
--
-- Content-Language: da
ContentLanguage :: HeaderName
-- | An alternate location for the returned data
--
-- Content-Location: /index.htm
ContentLocation :: HeaderName
-- | Where in a full body message this partial message belongs
--
-- Content-Range: bytes 21010-47021/47022
ContentRange :: HeaderName
-- | Content Security Policy definition.
--
-- Content-Security-Policy: default-src self
ContentSecurityPolicy :: HeaderName
-- | An identifier for a specific version of a resource, often a message
-- digest
--
-- ETag: "737060cd8c284d8af7ad3082f209582d"
ETag :: HeaderName
-- | Gives the date/time after which the response is considered stale (in
-- HTTP-date format as defined by RFC 7231)
--
-- Expires: Thu, 01 Dec 1994 16:00:00 GMT
Expires :: HeaderName
-- | The last modified date for the requested object (in HTTP-date
-- format as defined by RFC 7231)
--
-- Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
LastModified :: HeaderName
-- | Used to express a typed relationship with another resource, where the
-- relation type is defined by RFC 5988
--
-- Link: /feed; rel="alternate"
Link :: HeaderName
-- | Used in redirection, or when a new resource has been created.
--
-- Location: http://www.w3.org/pub/WWW/People.html
Location :: HeaderName
-- | Request authentication to access the proxy.
--
-- Proxy-Authenticate: Basic
ProxyAuthenticate :: HeaderName
-- | HTTP Public Key Pinning, announces hash of website's authentic TLS
-- certificate
--
-- Public-Key-Pins: max-age=2592000;
-- pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
PublicKeyPins :: HeaderName
-- | If an entity is temporarily unavailable, this instructs the client to
-- try again later. Value could be a specified period of time (in
-- seconds) or a HTTP-date.
--
-- Retry-After: 120 Retry-After: Fri, 07 Nov 2014 23:59:59 GMT
RetryAfter :: HeaderName
-- | An HTTP cookie
--
-- Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1
SetCookie :: HeaderName
-- | A HSTS Policy informing the HTTP client how long to cache the HTTPS
-- only policy and whether this applies to subdomains.
--
-- Strict-Transport-Security: max-age=16070400; includeSubDomains
StrictTransportSecurity :: HeaderName
-- | The Trailer general field value indicates that the given set of header
-- fields is present in the trailer of a message encoded with chunked
-- transfer coding.
--
-- Trailer: Max-Forwards
Trailer :: HeaderName
-- | The form of encoding used to safely transfer the entity to the user.
-- Currently defined methods are: chunked, compress, deflate, gzip,
-- identity.
--
-- Transfer-Encoding: chunked
TransferEncoding :: HeaderName
-- | Tells downstream proxies how to match future request headers to decide
-- whether the cached response can be used rather than requesting a fresh
-- one from the origin server.
--
-- Vary: * Vary: Accept-Language
Vary :: HeaderName
-- | Indicates the authentication scheme that should be used to access the
-- requested entity.
--
-- WWW-Authenticate: Basic
WWWAuthenticate :: HeaderName
-- | Represents mechanisms to interpret data types as header-compatible
-- values.
--
-- An instance of Encode n t captures a mechanism for treating
-- values of type t as valid data to substantiate the header
-- n.
--
-- Note: While this class allows the encoding of any value into a full
-- Unicode Text value, Headers do not generally accept most Unicode code
-- points. Be conservative in implementing this class.
class ReflectName n => HeaderEncode (n :: HeaderName) a
headerEncode :: HeaderEncode n a => Proxy n -> a -> Maybe Text
-- | Represents mechanisms to interpret data types as header-compatible
-- values.
--
-- An instance of Decode n t captures a mechanism for reading
-- values of type t from header data stored at header
-- n.
class ReflectName n => HeaderDecode (n :: HeaderName) a
headerDecode :: HeaderDecode n a => Proxy n -> Maybe Text -> Either String a
-- | Implements reflection of Name types into HeaderName
-- values for runtime use.
class ReflectName (n :: HeaderName)
module Serv.Cors
-- | A CorsPolicy interprets the request's provided Origin and the
-- current routing context to determine how to expose resources to the
-- requestor.
type Policy = Config -> Context -> AccessSet
-- | The CorsContext provides data from which we can make choices
-- about how to respond to CORS requests.
data Context
Context :: Text -> Set HeaderName -> Set HeaderName -> Set Verb -> Context
[origin] :: Context -> Text
[headersExpected] :: Context -> Set HeaderName
[headersReturned] :: Context -> Set HeaderName
[methodsAvailable] :: Context -> Set Verb
-- | Descrbes what parts of the response should be made available
-- cross-origin. The Monoid product on AccessSets permits all
-- accesses of either of the constituents.
data AccessSet
AccessSet :: Bool -> Set HeaderName -> Bool -> Set Verb -> Set HeaderName -> Maybe NominalDiffTime -> AccessSet
[originAllowed] :: AccessSet -> Bool
[headersExposed] :: AccessSet -> Set HeaderName
[credentialsAllowed] :: AccessSet -> Bool
[methodsAllowed] :: AccessSet -> Set Verb
[headersAllowed] :: AccessSet -> Set HeaderName
[maxAge] :: AccessSet -> Maybe NominalDiffTime
-- | Class describing types which describe CORS Policys.
class CorsPolicy m
corsPolicy :: CorsPolicy m => Proxy m -> Policy
-- | The PermitAll policy produces the permitAll
-- Policy.
data PermitAll
-- | The most permissive CORS Policy possible. Differs from Wildcard
-- in that it allows credentials. Max age is not provided (so no caching)
permitAll :: Policy
-- | Effects a wildcard policy which provides maximal cross-origin access
-- to all request origins. This disallows credentials use, however.
wildcard :: Policy
-- | Provides access to all origins which pass a predicate
predicateWhitelist :: (Text -> Bool) -> Policy
module Serv.ContentType
class HasMediaType ty
mediaType :: HasMediaType ty => Proxy ty -> MediaType
class HasMediaType ty => MimeEncode ty val
mimeEncode :: MimeEncode ty val => Proxy ty -> val -> ByteString
class HasMediaType ty => MimeDecode ty val
mimeDecode :: MimeDecode ty val => Proxy ty -> ByteString -> Either String val
-- | Builds a MediaType without parameters. Can produce an error if
-- either type is invalid.
(//) :: ByteString -> ByteString -> MediaType
-- | Adds a parameter to a MediaType. Can produce an error if either
-- string is invalid.
(/:) :: MediaType -> (ByteString, ByteString) -> MediaType
data TextPlain
data JSON
instance Serv.Internal.MediaType.HasMediaType Serv.ContentType.TextPlain
instance Serv.Internal.MediaType.MimeEncode Serv.ContentType.TextPlain Data.Text.Internal.Text
instance Serv.Internal.MediaType.HasMediaType Serv.ContentType.JSON
instance Data.Aeson.Types.ToJSON.ToJSON a => Serv.Internal.MediaType.MimeEncode Serv.ContentType.JSON a
instance Data.Aeson.Types.FromJSON.FromJSON a => Serv.Internal.MediaType.MimeDecode Serv.ContentType.JSON a
module Serv.Common
-- | RawText extracts as, like the name suggests, raw text from URI
-- segments and header values.
--
-- It exists as a default value for extensibility of typeclasses like
-- HeaderDecode and HeaderEncode
newtype RawText
RawText :: Text -> RawText
[getRawText] :: RawText -> Text
module Serv.Api
-- | 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. OneOf choices expresses this sequential
-- search along a set of sub-Api 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.
data Api star
[Endpoint] :: [Method star] -> Api star
[OneOf] :: [Api star] -> Api star
[Raw] :: Api star
[:>] :: Path star -> Api star -> Api star
-- | 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.
data Method star
[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
-- | 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
data Body star
[Body] :: [star] -> star -> Body star
[Empty] :: Body star
-- | 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.
data Path star
[Const] :: Symbol -> Path star
[HeaderAs] :: HeaderName -> Symbol -> Path star
[Seg] :: Symbol -> star -> Path star
[Header] :: HeaderName -> star -> Path star
[Wildcard] :: Path star
[Flag] :: Symbol -> Path star
[QueryParam] :: Symbol -> star -> Path star
[Cors] :: star -> Path star
data Verb
DELETE :: Verb
GET :: Verb
HEAD :: Verb
OPTIONS :: Verb
PATCH :: Verb
POST :: Verb
PUT :: Verb
-- | Equivalent to a tuple at both the type and kind levels, but has a
-- nicer syntax!
data Pair a b
(:::) :: a -> b -> Pair a b