package cohttp-async
CoHTTP implementation for the Async concurrency library
Install
Dune Dependency
Authors
Maintainers
Sources
cohttp-5.2.0.tbz
sha256=5dba8f26185603fb27f2ebfbadf701232ba8d1b2fe69e65e7253f21af7296f9b
sha512=84c6609964efa65e1d2e51563a985041d73810b85bc25f8e757b45397903e28b4e91979c49afdc8ff1fd79b202ff15f8ec3516ae6ea5c69a25bfa0a2ae46a7ea
doc/cohttp-async/Cohttp_async/Server/index.html
Module Cohttp_async.Server
Source
Source
val sexp_of_t :
('address -> Sexplib0.Sexp.t) ->
('listening_on -> Sexplib0.Sexp.t) ->
('address, 'listening_on) t ->
Sexplib0.Sexp.t
Source
type 'r respond_t =
?flush:bool ->
?headers:Cohttp.Header.t ->
?body:Body.t ->
Cohttp.Code.status_code ->
'r Async_kernel.Deferred.t
Source
type response_action = [
| `Expert of Cohttp.Response.t * (Async_unix.Reader.t -> Async_unix.Writer.t -> unit Async_kernel.Deferred.t)
| `Response of response
]
A request handler can respond in two ways:
- Using
`Response
, with aResponse.t
and aBody.t
. - Using
`Expert
, with aResponse.t
and an IO function that is expected to write the response body. The IO function has access to the underlyingAsync_unix.Reader.t
andAsync_unix.Writer.t
, which allows writing a response body more efficiently, stream a response or to switch protocols entirely (e.g. websockets). Processing of pipelined requests continue after theunitAsync_kernel.Deferred.t
is resolved. The connection can be closed by closing theAsync_unix.Reader.t
.
Resolve a URI and a docroot into a concrete local filename.
Deprecated. Please use Cohttp.Path.resolve_local_file.
Source
val respond_with_pipe :
?flush:bool ->
?headers:Cohttp.Header.t ->
?code:Cohttp.Code.status_code ->
string Async_kernel.Pipe.Reader.t ->
response Async_kernel.Deferred.t
Respond with a string
Pipe that provides the response string Pipe.Reader.t.
Source
val respond_string :
?flush:bool ->
?headers:Cohttp.Header.t ->
?status:Cohttp.Code.status_code ->
string ->
response Async_kernel.Deferred.t
Source
val respond_with_redirect :
?headers:Cohttp.Header.t ->
Uri.t ->
response Async_kernel.Deferred.t
Respond with a redirect to an absolute uri
Source
val respond_with_file :
?flush:bool ->
?headers:Cohttp.Header.t ->
?error_body:string ->
string ->
response Async_kernel.Deferred.t
Respond with file contents, and error_string Pipe.Async_unix.Reader.t
if the file isn't found
Source
val create_expert :
?max_connections:int ->
?backlog:int ->
?buffer_age_limit:Async_unix.Writer.buffer_age_limit ->
?mode:mode ->
on_handler_error:[ `Call of 'address -> exn -> unit | `Ignore | `Raise ] ->
('address, 'listening_on) Async.Tcp.Where_to_listen.t ->
(body:Body.t ->
'address ->
Request.t ->
response_action Async_kernel.Deferred.t) ->
('address, 'listening_on) t Async_kernel.Deferred.t
Build a HTTP server and expose the IO.ic
and IO.oc
s, based on the Tcp.Server
interface.
Source
val create :
?max_connections:int ->
?backlog:int ->
?buffer_age_limit:Async_unix.Writer.buffer_age_limit ->
?mode:Conduit_async.server ->
on_handler_error:[ `Call of 'address -> exn -> unit | `Ignore | `Raise ] ->
('address, 'listening_on) Async.Tcp.Where_to_listen.t ->
(body:Body.t -> 'address -> Request.t -> response Async_kernel.Deferred.t) ->
('address, 'listening_on) t Async_kernel.Deferred.t
Build a HTTP server, based on the Tcp.Server
interface
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>