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 configure_logger() -> Nil
Wisp’s logger setup needs to run before the HTTP server starts or you get raw Erlang crash reports instead of readable request logs. Wrapping it here keeps the boot sequence free of direct wisp imports.
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())