mist/handler

Types

pub type Handler =
  fn(request.Request(BitString)) -> response.Response(BitBuilder)
pub type HandlerError {
  InvalidRequest(DecodeError)
  NotFound
}

Constructors

  • InvalidRequest(DecodeError)
  • NotFound
pub type HandlerFunc =
  fn(Request(Body)) -> HandlerResponse
pub type HandlerResponse {
  Response(response: response.Response(HttpResponseBody))
  Upgrade(websocket.WebsocketHandler)
}

Constructors

  • Response(response: response.Response(HttpResponseBody))
  • Upgrade(websocket.WebsocketHandler)
pub type State {
  State(
    idle_timer: Option(process.Timer),
    upgraded_handler: Option(websocket.WebsocketHandler),
  )
}

Constructors

  • State(
      idle_timer: Option(process.Timer),
      upgraded_handler: Option(websocket.WebsocketHandler),
    )

Functions

pub fn new_state() -> State
pub fn with(handler: fn(Request(BitString)) ->
    Response(BitBuilder), max_body_limit: Int) -> fn(
  HandlerMessage,
  LoopState(State),
) -> Next(LoopState(State))

Creates a standard HTTP handler service to pass to mist.serve

pub fn with_func(handler: fn(Request(Body)) -> HandlerResponse) -> fn(
  HandlerMessage,
  LoopState(State),
) -> Next(LoopState(State))

This is a more flexible handler. It will allow you to upgrade a connection to a websocket connection, or deal with a regular HTTP req->resp workflow.

Search Document