package http_async

  1. Overview
  2. Docs
type error_handler = ?exn:Core.Exn.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 : ?where_to_listen:Async.Tcp.Where_to_listen.inet -> ?max_connections:int -> ?max_accepts_per_batch:int -> ?backlog:int -> ?socket:([ `Unconnected ], Async.Socket.Address.Inet.t) Async.Socket.t -> ?buffer_config:Buffer_config.t -> ?error_handler:error_handler -> ((Request.t * Body.Reader.t) -> (Response.t * Body.Writer.t) Async.Deferred.t) -> (Async.Socket.Address.Inet.t, int) 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:error_handler -> summary:string -> ((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.

OCaml

Innovation. Community. Security.