glisten

Types

Reasons that serve might fail

pub type StartError {
  ListenerClosed
  ListenerTimeout
  AcceptorTimeout
  AcceptorFailed(process.ExitReason)
  AcceptorCrashed(Dynamic)
}

Constructors

  • ListenerClosed
  • ListenerTimeout
  • AcceptorTimeout
  • AcceptorFailed(process.ExitReason)
  • AcceptorCrashed(Dynamic)

Functions

pub fn serve(port: Int, handler: fn(HandlerMessage, #(Socket, a)) ->
    Next(#(Socket, a)), initial_state: a) -> Result(
  Nil,
  StartError,
)

Sets up a TCP server listener at the provided port. Also takes the HttpHandler, which holds the handler function. There are currently two options for ease of use: http.handler and ws.handler.