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:
- 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
- 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 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().