dream/servers/mist/handler

Request handler for Mist server

This module provides handler creation functionality that converts Mist requests to Dream requests, routes them, and converts the response back to Mist format.

This is an internal module used by the Dream server implementation. Most applications won’t need to use this directly.

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

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