RequestContext

class gafaelfawr.handlers.util.RequestContext(request: web.Request, config: Config, logger: BoundLogger, redis: Redis)

Bases: object

Holds the incoming request and its surrounding context.

The primary reason for the existence of this class is to allow the functions involved in request processing to repeated rebind the request logger to include more information, without having to pass both the request and the logger separately to every function.

Attributes Summary

factory A factory for constructing Gafaelfawr components.

Methods Summary

from_request(request) Construct a RequestContext from an incoming request.

Attributes Documentation

factory

A factory for constructing Gafaelfawr components.

This is constructed on the fly at each reference to ensure that we get the latest logger, which may have additional bound context.

Methods Documentation

classmethod from_request(request: aiohttp.web_request.Request) → gafaelfawr.handlers.util.RequestContext

Construct a RequestContext from an incoming request.

Parameters:request (aiohttp.web.Request) – The incoming request.
Returns:context – The newly-created context.
Return type:RequestContext