Documentation

Std.Http.Server.Handler

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 to Body.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.

  • onFailure (self : σ) (error : IO.Error) : Async.Async Unit

    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.

  • onContinue (self : σ) (request : Request.Head) : Async.Async Bool

    Called when a request includes an Expect: 100-continue header. Return true to send a 100 Continue response and accept the body. If false is returned the server sends 417 Expectation Failed, disables keep-alive, and closes the request body reader. This function is guarded by Config.lingeringTimeout and may be cancelled on server shutdown. The default implementation always returns true.

Instances

    A stateless HTTP handler.

    Instances For
      @[implicit_reducible]
      Equations
      • One or more equations did not get rendered due to their size.

      Builds a StatelessHandler from a request-handling function.

      Equations
      Instances For

        Builds a StatelessHandler from all three callback functions.

        Equations
        Instances For

          Builds a StatelessHandler from a request function and a failure callback. Useful for attaching error logging to a handler.

          Equations
          Instances For

            Builds a StatelessHandler from a request function and a continue callback

            Equations
            Instances For