dream/servers/mist/handler

Values

pub fn create(
  router: router.Router(context, services),
  max_body_size: Int,
  template_context: context,
  services_instance: services,
  update_context: fn(context, String) -> context,
) -> fn(request.Request(mist.Connection)) -> response.Response(
  mist.ResponseData,
)

Create a request handler that converts Mist requests to Dream requests

This function creates the main request handler used by the Mist server. It handles the complete request/response cycle:

  1. Convert Mist request headers/metadata to Dream request
  2. Match route to determine if body should be buffered or streamed
  3. Read body (buffered) or wrap stream (streaming)
  4. Route the request through the router
  5. Convert Dream response back to Mist format
  6. Handle HTTP → WebSocket upgrades when a controller calls websocket.upgrade_websocket (the upgrade response is stashed and returned here instead of a normal HTTP response)

Parameters

  • router: The application’s router with all routes configured
  • max_body_size: Maximum allowed request body size in bytes
  • template_context: Template context to clone for each request
  • services_instance: Application services (database, cache, etc.)
  • update_context: Function to update context with request-specific data

Returns

A function that takes a Mist HTTP request and returns a Mist HTTP response. This function is what you pass to mist.new().

Search Document