package http_async

  1. Overview
  2. Docs
type error_handler = ?exn:Core.Exn.t -> ?request:Request.t -> Status.t -> (Response.t * Body.Writer.t) Async.Deferred.t

run_server_loop accepts a HTTP service, and returns a callback that can be used to drive the server loop created via Shuttle.Connection.listen. This allows the user to customize the Input_channel and Output_channel and have control over the various Server configuration options like accept_n, backlog and more.

val run : ?max_connections:int -> ?max_accepts_per_batch:int -> ?backlog:int -> ?socket:([ `Unconnected ], [< Async.Socket.Address.t ] as 'a) Async.Socket.t -> ?buffer_config:Buffer_config.t -> ?error_handler:('a -> error_handler) -> where_to_listen:('a, 'b) Async.Tcp.Where_to_listen.t -> ('a -> (Request.t * Body.Reader.t) -> (Response.t * Body.Writer.t) Async.Deferred.t) -> ('a, 'b) Async.Tcp.Server.t Async.Deferred.t

run sets up a Tcp.Server.t and drives the HTTP server loop with the user provided request-handler.

val run_command : ?interrupt:unit Async.Deferred.t -> ?readme:(unit -> string) -> ?error_handler:(Async.Socket.Address.Inet.t -> error_handler) -> summary:string -> (Async.Socket.Address.Inet.t -> (Request.t * Body.Reader.t) -> (Response.t * Body.Writer.t) Async.Deferred.t) -> Async.Command.t

run_command is similar to run but instead returns an Async.Command.t that can be used to start the async event loop from a program's entrypoint. If interrupt is provided, the server will be stopped when interrupt is fulfilled.


Innovation. Community. Security.