aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2023-03-28 19:56:45 +0100
committerTomasz Kramkowski <tomasz@kramkow.ski>2023-03-28 20:45:05 +0100
commit10425e109b4160e309fa8f32eabd13576b3ab5c7 (patch)
tree7fa63844cf29f0be1d248b758bca6008c4465e58
parent4177aa0c3bb345dbc31cc43c39007571d205c736 (diff)
downloadpaste-10425e109b4160e309fa8f32eabd13576b3ab5c7.tar.gz
paste-10425e109b4160e309fa8f32eabd13576b3ab5c7.tar.xz
paste-10425e109b4160e309fa8f32eabd13576b3ab5c7.zip
Use a list of middlewares instead of decorators
-rw-r--r--paste/__init__.py21
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)