A type class for handling HTTP server requests. Implement this class to define how the server
responds to incoming requests, failures, and Expect: 100-continue headers.
- ResponseBody : Type
Concrete body type produced by
onRequest. Defaults toBody.Any, but handlers may override it with any reader/writer-compatible body. - responseBodyInstance : Body (ResponseBody σ)
Body instance required by the connection loop for receiving response chunks.
- onRequest (self : σ) (request : Request Body.Stream) : Async.ContextAsync (Response (ResponseBody σ))
Called for each incoming HTTP request.
Called when an I/O or transport error occurs while processing a request (e.g. broken socket, handler exception). This is a notification only: the connection will close regardless of the handler's response. Use this for logging and metrics. The default implementation does nothing.
Called when a request includes an
Expect: 100-continueheader. Returntrueto send a100 Continueresponse and accept the body. Iffalseis returned the server sends417 Expectation Failed, disables keep-alive, and closes the request body reader. This function is guarded byConfig.lingeringTimeoutand may be cancelled on server shutdown. The default implementation always returnstrue.
Instances
A stateless HTTP handler.
- onRequest : Request Body.Stream → Async.ContextAsync (Response Body.Any)
Function called for each incoming request.
- onFailure : IO.Error → Async.Async Unit
Function called when an I/O or transport error occurs. The default does nothing.
- onContinue : Request.Head → Async.Async Bool
Function called when a request includes
Expect: 100-continue. Returntrueto accept the body orfalseto reject it with417 Expectation Failed. The default always accepts.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Builds a StatelessHandler from a request-handling function.
Equations
- Std.Http.Server.Handler.ofFn f = { onRequest := f }
Instances For
Builds a StatelessHandler from all three callback functions.
Equations
- Std.Http.Server.Handler.ofFns onRequest onFailure onContinue = { onRequest := onRequest, onFailure := onFailure, onContinue := onContinue }
Instances For
Builds a StatelessHandler from a request function and a failure callback. Useful for
attaching error logging to a handler.
Equations
- Std.Http.Server.Handler.withFailure handler onFailure = { onRequest := handler.onRequest, onFailure := onFailure, onContinue := handler.onContinue }
Instances For
Builds a StatelessHandler from a request function and a continue callback