glimr/http/middleware/load_session
Session Middleware
Loads the session for each request. Reads the session cookie, hydrates a session actor from the configured store, and persists changes after the handler returns. Separated from the Session type module to avoid an import cycle — Context has a Session field, and this middleware takes Context(app).
Values
pub fn run(
ctx: context.Context(app),
next: fn(context.Context(app)) -> response.Response(wisp.Body),
) -> response.Response(wisp.Body)
Starts a session for the current request. Reads the session cookie, loads data from the configured store, and provides a live session to the next handler. After the handler returns, persists changes and sets the cookie on the response.
This function’s signature matches the Middleware type, so it can be placed directly in middleware lists:
[serve_static.run, log_request.run, load_session.run]
|> middleware.apply(ctx, router)