diff options
author | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-03-28 19:56:45 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-03-28 20:45:05 +0100 |
commit | 10425e109b4160e309fa8f32eabd13576b3ab5c7 (patch) | |
tree | 7fa63844cf29f0be1d248b758bca6008c4465e58 | |
parent | 4177aa0c3bb345dbc31cc43c39007571d205c736 (diff) | |
download | paste-10425e109b4160e309fa8f32eabd13576b3ab5c7.tar.gz paste-10425e109b4160e309fa8f32eabd13576b3ab5c7.tar.xz paste-10425e109b4160e309fa8f32eabd13576b3ab5c7.zip |
Use a list of middlewares instead of decorators
-rw-r--r-- | paste/__init__.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/paste/__init__.py b/paste/__init__.py index 6e93923..c54791b 100644 --- a/paste/__init__.py +++ b/paste/__init__.py @@ -169,13 +169,7 @@ def authenticate(get_auth: Callable[[Env], Auth]) -> Middleware: return authenticate -@catch_exceptions -@validate_method -@options -@if_none_match -@open_database -@authenticate(lambda environ: Auth(environ["paste.db_conn"])) -def application(environ: Env, start_response: StartResponse) -> Response: +def application(environ: Env, start_response: StartResponse, /) -> Response: store = Store(environ["paste.db_conn"]) name = environ["PATH_INFO"] if environ["REQUEST_METHOD"] == "GET": @@ -243,3 +237,16 @@ def application(environ: Env, start_response: StartResponse) -> Response: return [] return simple_response(start_response, "404 Not Found") return simple_response(start_response, "500 Internal Server Error") + + +middlewares = [ + catch_exceptions, + validate_method, + options, + if_none_match, + open_database, + authenticate(lambda environ: Auth(environ["paste.db_conn"])), +] + +for m in reversed(middlewares): + application = m(application) |