allowed_hosts

class litestar.middleware.allowed_hosts.AllowedHostsMiddleware

Bases: ASGIMiddleware

Middleware ensuring the host of a request originated in a trusted host.

__init__(config: AllowedHostsConfig) None

Initialize AllowedHostsMiddleware.

Parameters:

config – An instance of AllowedHostsConfig.

async handle(scope: Scope, receive: Receive, send: Send, next_app: ASGIApp) None

Handle ASGI call.

Parameters:
  • scope – The ASGI connection scope.

  • receive – The ASGI receive function.

  • send – The ASGI send function

  • next_app – The next ASGI application in the middleware stack to call