From 1653394cf7267a3056e2fb5566b502cfb12b3187 Mon Sep 17 00:00:00 2001 From: pictuga Date: Sat, 4 Apr 2020 16:35:16 +0200 Subject: [PATCH] morss: cgi_dispatcher to be able to create extra functions --- morss/morss.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/morss/morss.py b/morss/morss.py index 9f15235..37a7185 100644 --- a/morss/morss.py +++ b/morss/morss.py @@ -651,6 +651,21 @@ def cgi_file_handler(environ, start_response, app): return app(environ, start_response) +dispatch_table = { + } + + +@middleware +def cgi_dispatcher(environ, start_response, app): + url, options = cgi_parse_environ(environ) + + for key in dispatch_table.keys(): + if key in options: + return dispatch_table[key](environ, start_response) + + return app(environ, start_response) + + @middleware def cgi_error_handler(environ, start_response, app): try: @@ -706,6 +721,7 @@ def main(): # mod_cgi app = cgi_app + app = cgi_dispatcher(app) app = cgi_error_handler(app) app = cgi_encode(app) @@ -727,6 +743,7 @@ def main(): app = cgi_app app = cgi_file_handler(app) + app = cgi_dispatcher(app) app = cgi_error_handler(app) app = cgi_encode(app)