Middleware interfaces and built-ins.
最初に以下の最小例でモジュール利用方法を確認し、その後 API リファレンスを参照してください。
from nexom.app.middleware import *
# このモジュールの関数・クラスを用途に合わせて呼び出します。
# 下の API リファレンスで各関数の引数と使い方を確認してください。
分類: public class
Middleware interface. A middleware receives the request, route args, and next handler. It must return a Response.
分類: special method
__call__(self, request: Request, args: dict[str, str | None], next_: Handler) -> Response
メソッドドキュメントは未定義です。
request / kind=positional-or-keyword / type=Request / 必須 / default=なしargs / kind=positional-or-keyword / type=dict[str, str | None] / 必須 / default=なしnext_ / kind=positional-or-keyword / type=Handler / 必須 / default=なしResponse
実装コード内の例外仕様を確認してください。
from nexom.app.middleware import Middleware
obj = Middleware(...)
result = obj.__call__(request=..., args="sample", next_=...)
print(result)
分類: public class
Build and execute a middleware chain.
分類: public method
wrap(self, handler: Handler) -> Handler
Wrap the given handler with middlewares (outer -> inner).
handler / kind=positional-or-keyword / type=Handler / 必須 / default=なしHandler
実装コード内の例外仕様を確認してください。
from nexom.app.middleware import MiddlewareChain
obj = MiddlewareChain(...)
result = obj.wrap(handler=...)
print(result)
分類: public class
Simple CORS middleware. Supports preflight OPTIONS and basic allow headers.
分類: special method
__init__(self, allowed_origins: list[str] | None = None, allowed_methods: list[str] | None = None, allowed_headers: list[str] | None = None, access_control_allow_credentials: bool = False, max_age: int | None = 600) -> None
メソッドドキュメントは未定義です。
allowed_origins / kind=positional-or-keyword / type=list[str] | None / 任意 / default=Noneallowed_methods / kind=positional-or-keyword / type=list[str] | None / 任意 / default=Noneallowed_headers / kind=positional-or-keyword / type=list[str] | None / 任意 / default=Noneaccess_control_allow_credentials / kind=positional-or-keyword / type=bool / 任意 / default=Falsemax_age / kind=positional-or-keyword / type=int | None / 任意 / default=600None
実装コード内の例外仕様を確認してください。
from nexom.app.middleware import CORSMiddleware
obj = CORSMiddleware(allowed_origins=None, allowed_methods=None, allowed_headers=None, access_control_allow_credentials=False, max_age=600)
分類: internal method
_is_allowed_origin(self, origin: str) -> bool
メソッドドキュメントは未定義です。
origin / kind=positional-or-keyword / type=str / 必須 / default=なしbool
実装コード内の例外仕様を確認してください。
from nexom.app.middleware import CORSMiddleware
obj = CORSMiddleware(...)
result = obj._is_allowed_origin(origin="sample")
print(result)
分類: internal method
_append_vary_origin(self, res: Response) -> None
メソッドドキュメントは未定義です。
res / kind=positional-or-keyword / type=Response / 必須 / default=なしNone
実装コード内の例外仕様を確認してください。
from nexom.app.middleware import CORSMiddleware
obj = CORSMiddleware(...)
result = obj._append_vary_origin(res=...)
print(result)
分類: special method
__call__(self, request: Request, args: dict[str, str | None], next_: Handler) -> Response
Apply CORS headers and handle preflight requests.
request / kind=positional-or-keyword / type=Request / 必須 / default=なしargs / kind=positional-or-keyword / type=dict[str, str | None] / 必須 / default=なしnext_ / kind=positional-or-keyword / type=Handler / 必須 / default=なしResponse
実装コード内の例外仕様を確認してください。
from nexom.app.middleware import CORSMiddleware
obj = CORSMiddleware(...)
result = obj.__call__(request=..., args="sample", next_=...)
print(result)
nexom.app.middlewareservices/venv/lib/python3.10/site-packages/nexom/app/middleware.py2026-03-14