std.http
Modules
std.http.types |
A minimal library for writing HTTP servers.
Types
type Method = String
type Failure =
| DontProcess
| Error String
Type used by handlers to indicate why they could not process a request
type StatusCode = Int
type Response = { status : Int, headers : Array (String, Array Byte) }
Values
#[implicit]
#[implicit]
let alternative : forall r . Alternative (Eff (HttpEffect r))
A monoid on applicative functors.
let status : {
ok : StatusCode,
moved_permanently : Int,
found : Int,
temporary_redirect : Int,
permanent_redirect : Int,
bad_request : StatusCode,
not_found : StatusCode,
internal_server_error : StatusCode
}
let empty_response : { status : StatusCode }
Returns OK
with an empty body
let get_request : forall r . Eff (HttpEffect r) Request
Retrieves the HTTP request
Takes a Handler
and a Request
tries to process the request
let get : forall r . Eff (HttpEffect r) ()
Handles Get
requests
let post : forall r . Eff (HttpEffect r) ()
Handles Post
requests
let path p : forall r . String -> Eff (HttpEffect r) ()
Processes this handler if uri
matches the request's uri
let is_match uri : forall r . String -> Eff (HttpEffect r) ()
let fail msg : forall a r . String -> Eff (HttpEffect r) a
Throws an exception which aborts the current handler. Can be caught with catch_error
let catch_error action catch : forall a r .
Eff (HttpEffect r) a
-> (String -> Eff (HttpEffect r) a)
-> Eff (HttpEffect r) a
Recovers from an exception thrown by fail
Show a
represents a conversion function from a
to a readable string.
let default_listen_settings : { port : Int, tls_cert : forall a . Option a }
let write_response bytes : forall r . Array Byte -> Eff (HttpEffect r) ()
Write bytes
to the http response