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:
- Convert Mist request headers/metadata to Dream request
- Match route to determine if body should be buffered or streamed
- Read body (buffered) or wrap stream (streaming)
- Route the request through the router
- Convert Dream response back to Mist format
Parameters
router: The application’s router with all routes configuredmax_body_size: Maximum allowed request body size in bytestemplate_context: Template context to clone for each requestservices_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().