Hcs.Endpoint

hcs · API reference

Global request entry point.

An endpoint composes global plugs and a router into a single Server.request -> Response.t handler suitable for Server.run. Use it for behavior that applies before route selection, such as request IDs, logging, recovery, security headers, or static assets.

type config = {
  secret_key_base : string;
  health_check : bool;
}
val default_config : config
type params_handler = Router.params -> Server.request -> Server.response
type t = {
  config : config;
  plugs : Pipeline.t;
  router : params_handler Router.t option;
  ws_handler : Server.ws_handler option;
}
val create : config -> t
val plug : 
  t ->
  ((Server.request -> Server.response) -> Server.request -> Server.response) ->
  t
val with_plug : 
  ((Server.request -> Server.response) -> Server.request -> Server.response) ->
  t ->
  t
val plug_pipeline : t -> Pipeline.t -> t
val with_pipeline : Pipeline.t -> t -> t
val (@>) : 
  t ->
  ((Server.request -> Server.response) -> Server.request -> Server.response) ->
  t
val (@>>) : t -> Pipeline.t -> t
val router : t -> params_handler Router.t -> t
val websocket : t -> Server.ws_handler -> t
val ws_handler : t -> Server.ws_handler option
val not_found_handler : 'a -> Response.t
val health_handler : 'a -> Response.t
val to_handler : t -> Server.request -> Server.response