glimr/http/glimr_mist
Glimr Mist Handler
Wisp has no built-in WebSocket support, but Loom Live needs it for real-time template updates. Rather than requiring users to manually wire up WebSocket routes, this drop-in replacement for wisp_mist.handler transparently intercepts the Loom WebSocket path (/loom/ws) while passing everything else through to wisp unchanged.
Values
pub fn handler(
handler: fn(request.Request(wisp.Connection)) -> response.Response(
wisp.Body,
),
secret_key_base: String,
) -> fn(request.Request(mist.Connection)) -> response.Response(
mist.ResponseData,
)
Users shouldn’t need to understand WebSocket plumbing to use Loom Live — swapping one import is enough. This function wraps wisp_mist.handler with a routing layer that intercepts Loom paths before they reach wisp, keeping the upgrade seamless and reversible.
// Before:
wisp_mist.handler(app.init(), config_app.key())
// After:
glimr_mist.handler(app.init(), config_app.key())