diff --git a/examples/hello_routed_world/src/hello_routed_world.e b/examples/hello_routed_world/src/hello_routed_world.e index ad5487c7..daad0e8e 100644 --- a/examples/hello_routed_world/src/hello_routed_world.e +++ b/examples/hello_routed_world/src/hello_routed_world.e @@ -10,7 +10,7 @@ class inherit ANY - ROUTED_APPLICATION + DEFAULT_URI_TEMPLATE_ROUTED_APPLICATION ROUTED_APPLICATION_HELPER @@ -29,18 +29,12 @@ feature {NONE} -- Initialization create_router do - debug - create {REQUEST_URI_ROUTER} router.make (5) - create {REQUEST_URI_TEMPLATE_ROUTER} router.make (5) - end - --- create {REQUEST_URI_ROUTER} router.make (5) - create {REQUEST_URI_TEMPLATE_ROUTER} router.make (5) + create router.make (5) end setup_router local - ra: REQUEST_AGENT_HANDLER + ra: REQUEST_AGENT_HANDLER [REQUEST_URI_TEMPLATE_HANDLER_CONTEXT] do router.map_agent ("/home", agent execute_home) @@ -107,7 +101,7 @@ feature -- Execution res.flush end - execute_home (ctx: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) + execute_home (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) do res.write_header (200, <<["Content-Type", "text/html"]>>) res.write_string ("Hello World ?!%N") @@ -171,33 +165,33 @@ feature -- Execution end end - handle_hello (ctx: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) + handle_hello (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) do execute_hello (req, res, Void, ctx) end - handle_anonymous_hello (ctx: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) + handle_anonymous_hello (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) do execute_hello (req, res, ctx.parameter ("name"), ctx) end - handle_method_any (ctx: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) + handle_method_any (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) do execute_hello (req, res, req.request_method, ctx) end - handle_method_get (ctx: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) + handle_method_get (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) do execute_hello (req, res, "GET", ctx) end - handle_method_post (ctx: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) + handle_method_post (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) do execute_hello (req, res, "POST", ctx) end - handle_method_get_or_post (ctx: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) + handle_method_get_or_post (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) do execute_hello (req, res, "GET or POST", ctx) end diff --git a/library/server/request/router/src/application/routed_application.e b/library/server/request/router/src/application/routed_application.e index 5cb24525..8c6d4313 100644 --- a/library/server/request/router/src/application/routed_application.e +++ b/library/server/request/router/src/application/routed_application.e @@ -5,7 +5,7 @@ note revision: "$Revision$" deferred class - ROUTED_APPLICATION + ROUTED_APPLICATION [H -> REQUEST_HANDLER [C], C -> REQUEST_HANDLER_CONTEXT] feature -- Setup @@ -30,7 +30,7 @@ feature -- Setup deferred end - router: REQUEST_ROUTER + router: REQUEST_ROUTER [H, C] -- Request router feature -- Execution diff --git a/library/server/request/router/src/default/default_request_uri_router.e b/library/server/request/router/src/default/default_request_uri_router.e new file mode 100644 index 00000000..2c96678f --- /dev/null +++ b/library/server/request/router/src/default/default_request_uri_router.e @@ -0,0 +1,39 @@ +note + description: "Summary description for {DEFAULT_REQUEST_URI_ROUTER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + DEFAULT_REQUEST_URI_ROUTER + +inherit + REQUEST_URI_ROUTER [REQUEST_HANDLER [REQUEST_URI_HANDLER_CONTEXT], REQUEST_URI_HANDLER_CONTEXT] + redefine + map_agent_with_request_methods + end +create + make + +feature -- Mapping + + map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: REQUEST_URI_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]]; + rqst_methods: detachable ARRAY [READABLE_STRING_8]) + local + h: REQUEST_AGENT_HANDLER [REQUEST_URI_HANDLER_CONTEXT] + do + create h.make (a_action) + map_with_request_methods (a_id, h, rqst_methods) + end + +note + copyright: "2011-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/request/router/src/default/default_request_uri_template_router.e b/library/server/request/router/src/default/default_request_uri_template_router.e new file mode 100644 index 00000000..8ed69b4c --- /dev/null +++ b/library/server/request/router/src/default/default_request_uri_template_router.e @@ -0,0 +1,40 @@ +note + description: "Summary description for {DEFAULT_REQUEST_URI_TEMPLATE_ROUTER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + DEFAULT_REQUEST_URI_TEMPLATE_ROUTER + +inherit + REQUEST_URI_TEMPLATE_ROUTER [REQUEST_HANDLER [REQUEST_URI_TEMPLATE_HANDLER_CONTEXT], REQUEST_URI_TEMPLATE_HANDLER_CONTEXT] + redefine + map_agent_with_request_methods + end + +create + make + +feature -- Mapping + + map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]]; + rqst_methods: detachable ARRAY [READABLE_STRING_8]) + local + h: REQUEST_AGENT_HANDLER [REQUEST_URI_TEMPLATE_HANDLER_CONTEXT] + do + create h.make (a_action) + map_with_request_methods (a_id, h, rqst_methods) + end + +note + copyright: "2011-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/request/router/src/default/default_routed_application.e b/library/server/request/router/src/default/default_routed_application.e new file mode 100644 index 00000000..1113a09f --- /dev/null +++ b/library/server/request/router/src/default/default_routed_application.e @@ -0,0 +1,23 @@ +note + description: "Summary description for {DEFAULT_ROUTED_APPLICATION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + DEFAULT_ROUTED_APPLICATION + +inherit + ROUTED_APPLICATION [REQUEST_HANDLER [REQUEST_HANDLER_CONTEXT], REQUEST_HANDLER_CONTEXT] + +note + copyright: "2011-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/request/router/src/default/default_uri_routed_application.e b/library/server/request/router/src/default/default_uri_routed_application.e new file mode 100644 index 00000000..831f134d --- /dev/null +++ b/library/server/request/router/src/default/default_uri_routed_application.e @@ -0,0 +1,30 @@ +note + description: "Summary description for {DEFAULT_URI_ROUTED_APPLICATION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + DEFAULT_URI_ROUTED_APPLICATION + +inherit + ROUTED_APPLICATION [REQUEST_HANDLER [REQUEST_URI_HANDLER_CONTEXT], REQUEST_URI_HANDLER_CONTEXT] + redefine + router + end + +feature -- Router + + router: DEFAULT_REQUEST_URI_ROUTER + +;note + copyright: "2011-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/request/router/src/default/default_uri_template_routed_application.e b/library/server/request/router/src/default/default_uri_template_routed_application.e new file mode 100644 index 00000000..155b1aa0 --- /dev/null +++ b/library/server/request/router/src/default/default_uri_template_routed_application.e @@ -0,0 +1,30 @@ +note + description: "Summary description for {DEFAULT_URI_TEMPLATE_ROUTED_APPLICATION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + DEFAULT_URI_TEMPLATE_ROUTED_APPLICATION + +inherit + ROUTED_APPLICATION [REQUEST_HANDLER [REQUEST_URI_TEMPLATE_HANDLER_CONTEXT], REQUEST_URI_TEMPLATE_HANDLER_CONTEXT] + redefine + router + end + +feature -- Router + + router: DEFAULT_REQUEST_URI_TEMPLATE_ROUTER + +;note + copyright: "2011-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/request/router/src/handler/request_agent_handler.e b/library/server/request/router/src/handler/request_agent_handler.e index 545df575..962cebc4 100644 --- a/library/server/request/router/src/handler/request_agent_handler.e +++ b/library/server/request/router/src/handler/request_agent_handler.e @@ -5,10 +5,10 @@ note revision: "$Revision$" class - REQUEST_AGENT_HANDLER + REQUEST_AGENT_HANDLER [C -> REQUEST_HANDLER_CONTEXT] inherit - REQUEST_HANDLER + REQUEST_HANDLER [C] create make @@ -23,11 +23,11 @@ feature -- Initialization feature -- Access - action: PROCEDURE [ANY, TUPLE [ctx: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]] + action: PROCEDURE [ANY, TUPLE [ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]] feature -- Execution - execute_application (ctx: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) + execute_application (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) do action.call ([ctx, req, res]) end diff --git a/library/server/request/router/src/handler/request_handler.e b/library/server/request/router/src/handler/request_handler.e index 9c816624..c87056ce 100644 --- a/library/server/request/router/src/handler/request_handler.e +++ b/library/server/request/router/src/handler/request_handler.e @@ -5,7 +5,7 @@ note revision: "$Revision$" deferred class - REQUEST_HANDLER + REQUEST_HANDLER [C -> REQUEST_HANDLER_CONTEXT] inherit ANY @@ -37,7 +37,7 @@ feature -- Status report feature -- Execution - execute (a_hdl_context: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) + execute (a_hdl_context: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) -- Execute request handler require is_valid_context: is_valid_context (req) @@ -60,7 +60,7 @@ feature -- Execution retry end - execute_application (a_hdl_context: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) + execute_application (a_hdl_context: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) -- Execute request handler deferred end diff --git a/library/server/request/router/src/router/request_router.e b/library/server/request/router/src/router/request_router.e index a16c9cd7..8177478d 100644 --- a/library/server/request/router/src/router/request_router.e +++ b/library/server/request/router/src/router/request_router.e @@ -5,9 +5,9 @@ note revision: "$Revision$" deferred class - REQUEST_ROUTER + REQUEST_ROUTER [H -> REQUEST_HANDLER [C], C -> REQUEST_HANDLER_CONTEXT] -feature -- Registration +feature -- Mapping map_default (r: like default_handler) -- Map default handler @@ -17,28 +17,33 @@ feature -- Registration set_default_handler (r) end - map (a_id: READABLE_STRING_8; h: REQUEST_HANDLER) + map (a_id: READABLE_STRING_8; h: H) -- Map handler `h' with `a_id' do map_with_request_methods (a_id, h, Void) end - map_with_request_methods (a_id: READABLE_STRING_8; h: REQUEST_HANDLER; rqst_methods: detachable ARRAY [READABLE_STRING_8]) + map_with_request_methods (a_id: READABLE_STRING_8; h: H; rqst_methods: detachable ARRAY [READABLE_STRING_8]) -- Map handler `h' with `a_id' and `rqst_methods' deferred end - map_agent (a_id: READABLE_STRING_8; a_action: like {REQUEST_AGENT_HANDLER}.action) + map_agent (a_id: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]]) do map_agent_with_request_methods (a_id, a_action, Void) end - map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: like {REQUEST_AGENT_HANDLER}.action; rqst_methods: detachable ARRAY [READABLE_STRING_8]) + map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]]; + rqst_methods: detachable ARRAY [READABLE_STRING_8]) local - h: REQUEST_AGENT_HANDLER + rah: REQUEST_AGENT_HANDLER [C] do - create h.make (a_action) - map_with_request_methods (a_id, h, rqst_methods) + create rah.make (a_action) + if attached {H} rah as h then + map_with_request_methods (a_id, h, rqst_methods) + else + check valid_agent_handler: False end + end end feature -- Execution @@ -50,7 +55,7 @@ feature -- Execution Result := dispatch_and_return_handler (req, res) /= Void end - dispatch_and_return_handler (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER): like default_handler + dispatch_and_return_handler (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER): detachable H -- Dispatch `req, res' to the associated handler -- And return this handler -- If Result is Void, this means no handler was found. @@ -77,7 +82,7 @@ feature -- Execution feature -- Traversing - new_cursor: ITERATION_CURSOR [TUPLE [handler: REQUEST_HANDLER; resource: READABLE_STRING_8; request_methods: detachable ARRAY [READABLE_STRING_8]]] + new_cursor: ITERATION_CURSOR [TUPLE [handler: H; resource: READABLE_STRING_8; request_methods: detachable ARRAY [READABLE_STRING_8]]] -- Fresh cursor associated with current structure deferred ensure @@ -86,7 +91,7 @@ feature -- Traversing feature {NONE} -- Access: Implementation - handler (req: WGI_REQUEST): detachable TUPLE [handler: attached like default_handler; context: like default_handler_context] + handler (req: WGI_REQUEST): detachable TUPLE [handler: H; context: like default_handler_context] -- Handler whose map matched with `req' require req_valid: req /= Void and then req.path_info /= Void @@ -146,12 +151,12 @@ feature {NONE} -- Implementation default_handler_set: h = default_handler end - default_handler: detachable REQUEST_HANDLER + default_handler: detachable H -- Default handler deferred end - default_handler_context (req: WGI_REQUEST): REQUEST_HANDLER_CONTEXT + default_handler_context (req: WGI_REQUEST): C -- Default handler context associated with `default_handler' require has_default_handler: default_handler /= Void diff --git a/library/server/request/router/src/router/request_uri_router.e b/library/server/request/router/src/router/request_uri_router.e index 4480a354..eb272ad7 100644 --- a/library/server/request/router/src/router/request_uri_router.e +++ b/library/server/request/router/src/router/request_uri_router.e @@ -5,10 +5,10 @@ note revision: "$Revision$" class - REQUEST_URI_ROUTER + REQUEST_URI_ROUTER [H -> REQUEST_HANDLER [C], C -> REQUEST_URI_HANDLER_CONTEXT create make end] inherit - REQUEST_ROUTER + REQUEST_ROUTER [H, C] create make @@ -23,16 +23,16 @@ feature -- Initialization feature -- Registration - map_with_request_methods (p: READABLE_STRING_8; h: REQUEST_HANDLER; rqst_methods: detachable ARRAY [READABLE_STRING_8]) + map_with_request_methods (p: READABLE_STRING_8; h: H; rqst_methods: detachable ARRAY [READABLE_STRING_8]) do handlers.force ([h, p, formatted_request_methods (rqst_methods)]) end feature {NONE} -- Access: Implementation - handler (req: WGI_REQUEST): detachable TUPLE [handler: REQUEST_HANDLER; context: like default_handler_context] + handler (req: WGI_REQUEST): detachable TUPLE [handler: H; context: like default_handler_context] local - h: detachable REQUEST_HANDLER + h: detachable H ctx: detachable like default_handler_context do h := handler_by_path (req.path_info, req.request_method) @@ -54,7 +54,7 @@ feature {NONE} -- Access: Implementation end end - smart_handler (req: WGI_REQUEST): detachable TUPLE [path: READABLE_STRING_8; handler: REQUEST_HANDLER] + smart_handler (req: WGI_REQUEST): detachable TUPLE [path: READABLE_STRING_8; handler: H] require req_valid: req /= Void and then req.path_info /= Void do @@ -63,7 +63,7 @@ feature {NONE} -- Access: Implementation req_path_info_unchanged: req.path_info.same_string (old req.path_info) end - handler_by_path (a_path: READABLE_STRING_GENERAL; rqst_method: READABLE_STRING_GENERAL): detachable REQUEST_HANDLER + handler_by_path (a_path: READABLE_STRING_GENERAL; rqst_method: READABLE_STRING_GENERAL): detachable H require a_path_valid: a_path /= Void local @@ -86,13 +86,13 @@ feature {NONE} -- Access: Implementation a_path_unchanged: a_path.same_string (old a_path) end - smart_handler_by_path (a_path: READABLE_STRING_8; rqst_method: READABLE_STRING_GENERAL): detachable TUPLE [path: READABLE_STRING_8; handler: REQUEST_HANDLER] + smart_handler_by_path (a_path: READABLE_STRING_8; rqst_method: READABLE_STRING_GENERAL): detachable TUPLE [path: READABLE_STRING_8; handler: H] require a_path_valid: a_path /= Void local p: INTEGER l_context_path, l_path: READABLE_STRING_8 - h: detachable REQUEST_HANDLER + h: detachable H do l_context_path := context_path (a_path) from @@ -116,18 +116,21 @@ feature {NONE} -- Access: Implementation feature {NONE} -- Context factory - handler_context (p: detachable STRING; req: WGI_REQUEST): like default_handler_context + handler_context (p: detachable STRING; req: WGI_REQUEST): C + local + ctx: C do if p /= Void then - create {REQUEST_URI_HANDLER_CONTEXT} Result.make (req, p) + create ctx.make (req, p) else - create {REQUEST_URI_HANDLER_CONTEXT} Result.make (req, req.path_info) + create ctx.make (req, req.path_info) end + Result := ctx end feature -- Access - new_cursor: ITERATION_CURSOR [TUPLE [handler: REQUEST_HANDLER; resource: READABLE_STRING_8; request_methods: detachable ARRAY [READABLE_STRING_8]]] + new_cursor: ITERATION_CURSOR [TUPLE [handler: H; resource: READABLE_STRING_8; request_methods: detachable ARRAY [READABLE_STRING_8]]] -- Fresh cursor associated with current structure do Result := handlers.new_cursor @@ -135,7 +138,7 @@ feature -- Access feature {NONE} -- Implementation - handlers: ARRAYED_LIST [TUPLE [handler: REQUEST_HANDLER; resource: READABLE_STRING_8; request_methods: detachable ARRAY [READABLE_STRING_8]]] + handlers: ARRAYED_LIST [TUPLE [handler: H; resource: READABLE_STRING_8; request_methods: detachable ARRAY [READABLE_STRING_8]]] -- Handlers indexed by the template expression -- see `templates' @@ -166,14 +169,14 @@ feature {NONE} -- Implementation feature {NONE} -- Default: implementation - default_handler: detachable REQUEST_HANDLER + default_handler: detachable H set_default_handler (h: like default_handler) do default_handler := h end - default_handler_context (req: WGI_REQUEST): REQUEST_HANDLER_CONTEXT + default_handler_context (req: WGI_REQUEST): C do Result := handler_context (Void, req) end diff --git a/library/server/request/router/src/router/request_uri_template_router.e b/library/server/request/router/src/router/request_uri_template_router.e index e73e3d11..4183b329 100644 --- a/library/server/request/router/src/router/request_uri_template_router.e +++ b/library/server/request/router/src/router/request_uri_template_router.e @@ -5,10 +5,10 @@ note revision: "$Revision$" class - REQUEST_URI_TEMPLATE_ROUTER + REQUEST_URI_TEMPLATE_ROUTER [H -> REQUEST_HANDLER [C], C -> REQUEST_URI_TEMPLATE_HANDLER_CONTEXT create make end] inherit - REQUEST_ROUTER + REQUEST_ROUTER [H, C] create make @@ -24,25 +24,25 @@ feature -- Initialization feature -- Registration - map_with_uri_template (uri: URI_TEMPLATE; h: REQUEST_HANDLER) + map_with_uri_template (uri: URI_TEMPLATE; h: H) do map_with_uri_template_and_request_methods (uri, h, Void) end - map_with_uri_template_and_request_methods (uri: URI_TEMPLATE; h: REQUEST_HANDLER; rqst_methods: detachable ARRAY [READABLE_STRING_8]) + map_with_uri_template_and_request_methods (uri: URI_TEMPLATE; h: H; rqst_methods: detachable ARRAY [READABLE_STRING_8]) do handlers.force ([h, uri.template, formatted_request_methods (rqst_methods)]) templates.force (uri, uri.template) end - map_with_request_methods (tpl: READABLE_STRING_8; h: REQUEST_HANDLER; rqst_methods: detachable ARRAY [READABLE_STRING_8]) + map_with_request_methods (tpl: READABLE_STRING_8; h: H; rqst_methods: detachable ARRAY [READABLE_STRING_8]) local uri: URI_TEMPLATE do create uri.make (tpl) map_with_uri_template_and_request_methods (uri, h, rqst_methods) end - + feature {NONE} -- Access: Implementation handler (req: WGI_REQUEST): detachable TUPLE [handler: attached like default_handler; context: like default_handler_context] @@ -76,18 +76,18 @@ feature {NONE} -- Access: Implementation feature {NONE} -- Context factory - handler_context (p: detachable STRING; req: WGI_REQUEST; tpl: URI_TEMPLATE; tpl_res: URI_TEMPLATE_MATCH_RESULT): like default_handler_context + handler_context (p: detachable STRING; req: WGI_REQUEST; tpl: URI_TEMPLATE; tpl_res: URI_TEMPLATE_MATCH_RESULT): C do if p /= Void then - create {REQUEST_URI_TEMPLATE_HANDLER_CONTEXT} Result.make (req, tpl, tpl_res, p) + create Result.make (req, tpl, tpl_res, p) else - create {REQUEST_URI_TEMPLATE_HANDLER_CONTEXT} Result.make (req, tpl, tpl_res, req.path_info) + create Result.make (req, tpl, tpl_res, req.path_info) end end feature -- Access: ITERABLE - new_cursor: ITERATION_CURSOR [TUPLE [handler: REQUEST_HANDLER; resource: READABLE_STRING_8; request_methods: detachable ARRAY [READABLE_STRING_8]]] + new_cursor: ITERATION_CURSOR [TUPLE [handler: H; resource: READABLE_STRING_8; request_methods: detachable ARRAY [READABLE_STRING_8]]] -- Fresh cursor associated with current structure do Result := handlers.new_cursor @@ -95,7 +95,7 @@ feature -- Access: ITERABLE feature {NONE} -- Implementation - handlers: ARRAYED_LIST [TUPLE [handler: REQUEST_HANDLER; resource: READABLE_STRING_8; request_methods: detachable ARRAY [READABLE_STRING_8]]] + handlers: ARRAYED_LIST [TUPLE [handler: H; resource: READABLE_STRING_8; request_methods: detachable ARRAY [READABLE_STRING_8]]] -- Handlers indexed by the template expression -- see `templates' @@ -126,16 +126,19 @@ feature {NONE} -- Implementation feature {NONE} -- Default: implementation - default_handler: detachable REQUEST_HANDLER + default_handler: detachable H set_default_handler (h: like default_handler) do default_handler := h end - default_handler_context (req: WGI_REQUEST): REQUEST_HANDLER_CONTEXT + default_handler_context (req: WGI_REQUEST): C + local + tpl: URI_TEMPLATE do - create {REQUEST_URI_HANDLER_CONTEXT} Result.make (req, "/") + create tpl.make ("/") + Result := handler_context ("/", req, tpl, create {URI_TEMPLATE_MATCH_RESULT}.make_empty) end ;note