package http_async

  1. Overview
  2. Docs
type error_handler = ?exn:Core.Exn.t -> Status.t -> Service.response Async.Deferred.t
val run_server_loop : ?error_handler:error_handler -> Service.t -> Shuttle.Input_channel.t -> Shuttle.Output_channel.t -> unit 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 -> ?initial_buffer_size:int -> ?error_handler:error_handler -> Service.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 Service.t.

val run_command : ?interrupt:unit Async.Deferred.t -> ?readme:(unit -> string) -> ?error_handler:error_handler -> summary:string -> Service.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.