python_template_server.middleware

Middleware module for server.

class python_template_server.middleware.RequestLoggingMiddleware(app)[source]

Middleware to log incoming requests and responses.

__init__(app)[source]

Initialize the RequestLoggingMiddleware.

async dispatch(request, call_next)[source]

Log request and response details.

Return type:

Response

class python_template_server.middleware.SecurityHeadersMiddleware(app, hsts_max_age, csp)[source]

Middleware to add security headers to all responses.

__init__(app, hsts_max_age, csp)[source]

Initialize the SecurityHeadersMiddleware.

async dispatch(request, call_next)[source]

Add security headers to the response.

Return type:

Response

Modules

request_logging_middleware

Middleware to log incoming requests and responses.

security_headers_middleware

Middleware to add security headers to all responses.