Idris2Doc : HTTP.API.Server.Interface

HTTP.API.Server.Interface

(source)

Reexports

importpublic HTTP.API
importpublic HTTP.Prog
importpublic HTTP.Request
importpublic HTTP.Response

Definitions

interfaceServe : Type->Type
  Interface for integrating a partial description of a
HTTP endpoint and using to extract variables from the
HTTP request and make adjustments to the server response.

Parameters: a
Methods:
0Constraint : a->Type
  Auto-implicit argument required by and passed to the
utility functions of this interface.
0InTypes : a->ListType
  Types of values extracted from the HTTP request
in function `fromRequest`.
0OutTypes : a->ListType
  Types of values needed to adjust the HTTP response
in `adjResponse`.
outs : (v : a) ->TList (OutTypesv)
  `TList` representation of `OutTypes`. This is required
to split the `OutTypes` of several endpoint descriptions and
pass each of them to the proper description.
canHandle : (v : a) ->Constraintv=>Request->Bool
  Returns `True`, if this endpoint description can process
the current HTTP request.

In general, a HTTP server consists of many endpoints, and
the first, for which `canHandle` returns `True`, will
get to process the request. If it then fails to do so
(by failing with a `RequestErr` in `fromRequest` or `adjResposnse`,
the request is considered to be invalid and no other endpoint
handler is tried. Instead, a proper error response is sent to
the client.
fromRequest : (v : a) ->Constraintv=>Request->Handler (HList (InTypesv))
  Tries to analyze the current HTTP request and extract
a heterogeneous list of `InTypes` from it.
adjResponse : (v : a) ->Constraintv=>HList (OutTypesv) ->Request->Response->HandlerResponse
  Takes the `OutTypes` and uses them to adjust the HTTP response.

Implementations:
ServeReqContent
ServeReqEnv
ServeReqHeaders
ServeReqMethod
ServeReqPath
ServeReqQuery
0Constraint : Servea=>a->Type
  Auto-implicit argument required by and passed to the
utility functions of this interface.

Totality: total
Visibility: public export
0InTypes : Servea=>a->ListType
  Types of values extracted from the HTTP request
in function `fromRequest`.

Totality: total
Visibility: public export
0OutTypes : Servea=>a->ListType
  Types of values needed to adjust the HTTP response
in `adjResponse`.

Totality: total
Visibility: public export
outs : {auto__con : Servea} -> (v : a) ->TList (OutTypesv)
  `TList` representation of `OutTypes`. This is required
to split the `OutTypes` of several endpoint descriptions and
pass each of them to the proper description.

Totality: total
Visibility: public export
canHandle : {auto__con : Servea} -> (v : a) ->Constraintv=>Request->Bool
  Returns `True`, if this endpoint description can process
the current HTTP request.

In general, a HTTP server consists of many endpoints, and
the first, for which `canHandle` returns `True`, will
get to process the request. If it then fails to do so
(by failing with a `RequestErr` in `fromRequest` or `adjResposnse`,
the request is considered to be invalid and no other endpoint
handler is tried. Instead, a proper error response is sent to
the client.

Totality: total
Visibility: public export
fromRequest : {auto__con : Servea} -> (v : a) ->Constraintv=>Request->Handler (HList (InTypesv))
  Tries to analyze the current HTTP request and extract
a heterogeneous list of `InTypes` from it.

Totality: total
Visibility: public export
adjResponse : {auto__con : Servea} -> (v : a) ->Constraintv=>HList (OutTypesv) ->Request->Response->HandlerResponse
  Takes the `OutTypes` and uses them to adjust the HTTP response.

Totality: total
Visibility: public export
0Constraints : AllServets=>HListts->ListType
  Computes the list of constraints required to process a
single endpoint description.

Totality: total
Visibility: public export
0AllInTypes : AllServets=>HListts->ListType
  Computes the list of types of values extracted from the HTTP request
by a single endpoint description.

Totality: total
Visibility: public export
0AllOutTypes : AllServets=>HListts->ListType
  Computes the list of type of values used to adjust the HTTP response
by a single endpoint description.

Totality: total
Visibility: public export
allOuts : {auto{conArg:17993} : AllServets} -> (endpoint : HListts) ->TList (AllOutTypesendpoint)
  Computes a `TList` representation of the outtypes of an entpoint.

Totality: total
Visibility: public export
0EndpointHandler : AllServets=>HListts->Type
  Function type for the handler of a single endpoint of a HTTP server.

Totality: total
Visibility: public export
canServe : {autoall : AllServets} -> (endpoint : HListts) ->HList (Constraintsendpoint) =>Request->Bool
  Returns `True` if the given endpoint can serve the current
HTTP request

Totality: total
Visibility: export
serveEndpoint : {autoall : AllServets} -> (endpoint : HListts) ->HList (Constraintsendpoint) =>EndpointHandlerendpoint->Request->HandlerResponse
  Processes a HTTP request at the given HTTP endpoint.

This proceeds in three steps:

1. The necessary values are extracted from the request
by invoking all `fromRequest` functions and concatenating
the results.

2. The extracted values are passed to the endpoint handler
(of type `EndpointHandler endpoint`), which produces the values
required to make adjustments to the HTTP response.

3. The values from (2) are split up and passed to the individual
`adjResponse` runctions, which adjust the (initially empty)
HTTP response accordingly.

Totality: total
Visibility: export