diff --git a/library/server/wsf/router/support/starts_with/wsf_starts_with_mapping_i.e b/library/server/wsf/router/support/starts_with/wsf_starts_with_mapping_i.e index 1a1a8435..e89da11b 100644 --- a/library/server/wsf/router/support/starts_with/wsf_starts_with_mapping_i.e +++ b/library/server/wsf/router/support/starts_with/wsf_starts_with_mapping_i.e @@ -47,26 +47,22 @@ feature -- Documentation feature -- Status - is_mapping (req: WSF_REQUEST; a_router: WSF_ROUTER): BOOLEAN + is_mapping (a_path: READABLE_STRING_8; req: WSF_REQUEST; a_router: WSF_ROUTER): BOOLEAN -- local - p: READABLE_STRING_8 s: like based_uri do - p := path_from_request (req) s := based_uri (uri, a_router) - Result := p.starts_with (s) + Result := a_path.starts_with (s) end - try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER) + try (a_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER) -- local - p: READABLE_STRING_8 s: like based_uri do - p := path_from_request (req) s := based_uri (uri, a_router) - if p.starts_with (s) then + if a_path.starts_with (s) then sess.set_dispatched_handler (handler) a_router.execute_before (Current) execute_handler (handler, s, req, res) @@ -113,7 +109,7 @@ invariant uri_attached: uri /= Void note - copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/router/support/uri/wsf_uri_mapping_i.e b/library/server/wsf/router/support/uri/wsf_uri_mapping_i.e index 7301fb3d..105bc03d 100644 --- a/library/server/wsf/router/support/uri/wsf_uri_mapping_i.e +++ b/library/server/wsf/router/support/uri/wsf_uri_mapping_i.e @@ -50,13 +50,13 @@ feature -- Documentation feature -- Status - is_mapping (req: WSF_REQUEST; a_router: WSF_ROUTER): BOOLEAN + is_mapping (a_path: READABLE_STRING_8; req: WSF_REQUEST; a_router: WSF_ROUTER): BOOLEAN -- local p: READABLE_STRING_8 l_uri: like uri do - p := path_from_request (req) + p := a_path l_uri := based_uri (uri, a_router) if l_uri.ends_with ("/") then if not p.ends_with ("/") then @@ -72,10 +72,10 @@ feature -- Status end end - try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER) + try (a_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER) -- do - if is_mapping (req, a_router) then + if is_mapping (a_path, req, a_router) then sess.set_dispatched_handler (handler) a_router.execute_before (Current) execute_handler (handler, req, res) @@ -106,7 +106,7 @@ feature {NONE} -- Implementation end note - copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/router/support/uri_template/wsf_uri_template_mapping_i.e b/library/server/wsf/router/support/uri_template/wsf_uri_template_mapping_i.e index 786d2af6..5c3a0ede 100644 --- a/library/server/wsf/router/support/uri_template/wsf_uri_template_mapping_i.e +++ b/library/server/wsf/router/support/uri_template/wsf_uri_template_mapping_i.e @@ -57,36 +57,32 @@ feature -- Documentation feature -- Status - is_mapping (req: WSF_REQUEST; a_router: WSF_ROUTER): BOOLEAN + is_mapping (a_path: READABLE_STRING_8; req: WSF_REQUEST; a_router: WSF_ROUTER): BOOLEAN -- local tpl: URI_TEMPLATE - p: READABLE_STRING_8 do - p := path_from_request (req) tpl := based_uri_template (template, a_router) - Result := tpl.match (p) /= Void + Result := tpl.match (a_path) /= Void end - try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER) + try (a_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER) -- local tpl: URI_TEMPLATE - p: READABLE_STRING_8 new_src: detachable WSF_REQUEST_PATH_PARAMETERS_PROVIDER do - p := path_from_request (req) tpl := based_uri_template (template, a_router) - if attached tpl.match (p) as tpl_res then + if attached tpl.match (a_path) as tpl_res then sess.set_dispatched_handler (handler) a_router.execute_before (Current) - --| Applied the context to the request - --| in practice, this will fill the {WSF_REQUEST}.path_parameters + --| Applied the context to the request + --| in practice, this will fill the {WSF_REQUEST}.path_parameters create new_src.make (tpl_res.path_variables.count, tpl_res.path_variables) new_src.apply (req) execute_handler (handler, req, res) - --| Revert {WSF_REQUEST}.path_parameters_source to former value - --| In case the request object passed by other handler that alters its values. + --| Revert {WSF_REQUEST}.path_parameters_source to former value + --| In case the request object passed by other handler that alters its values. new_src.revert (req) a_router.execute_after (Current) end @@ -126,7 +122,7 @@ feature {NONE} -- Implementation end note - copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/router/wsf_router.e b/library/server/wsf/router/wsf_router.e index bac65e0e..df7d4b43 100644 --- a/library/server/wsf/router/wsf_router.e +++ b/library/server/wsf/router/wsf_router.e @@ -170,6 +170,20 @@ feature -- Basic operations Result := sess.dispatched_handler end +feature {WSF_ROUTER_MAPPING} -- Dispatch helper + + path_to_dispatch (req: WSF_REQUEST): READABLE_STRING_8 + -- Path used by the router, to apply url dispatching of request `req'. + -- This can be redefined in descendant, to apply various url mapping, or aliasing + -- if needed, or for other purpose. + require + req_attached: req /= Void + do + Result := req.percent_encoded_path_info + ensure + path_from_request_attached: Result /= Void + end + feature {NONE} -- Dispatch implementation router_dispatch (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION) @@ -203,7 +217,9 @@ feature {NONE} -- Dispatch implementation a_request_method_attached: a_request_method /= Void local m: WSF_ROUTER_MAPPING + p: like path_to_dispatch do + p := path_to_dispatch (req) across mappings as c until @@ -212,7 +228,7 @@ feature {NONE} -- Dispatch implementation if attached c.item as l_info then if is_matching_request_methods (a_request_method, l_info.request_methods) then m := l_info.mapping - m.try (req, res, sess, Current) + m.try (p, req, res, sess, Current) end end end @@ -320,16 +336,17 @@ feature -- Status report local m: WSF_ROUTER_MAPPING l_rqsmethods: detachable WSF_REQUEST_METHODS + p: like path_to_dispatch do create Result - + p := path_to_dispatch (req) across mappings as c loop m := c.item.mapping if attached {WSF_ROUTING_HANDLER} m.handler as l_routing then l_rqsmethods := l_routing.router.allowed_methods_for_request (req) - elseif m.is_mapping (req, Current) then + elseif m.is_mapping (p, req, Current) then l_rqsmethods := c.item.request_methods else l_rqsmethods := Void @@ -576,7 +593,7 @@ invariant pre_execution_actions_attached: pre_execution_actions /= Void note - copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/router/wsf_router_mapping.e b/library/server/wsf/router/wsf_router_mapping.e index 9a2a3135..37ee0dbf 100644 --- a/library/server/wsf/router/wsf_router_mapping.e +++ b/library/server/wsf/router/wsf_router_mapping.e @@ -56,18 +56,20 @@ feature -- Status report feature -- Status - is_mapping (req: WSF_REQUEST; a_router: WSF_ROUTER): BOOLEAN - -- Does `Current' accept `req' when using `a_router'? + is_mapping (a_path: READABLE_STRING_8; req: WSF_REQUEST; a_router: WSF_ROUTER): BOOLEAN + -- Does `Current' accept path `a_path' and request `req' when using `a_router'? require + a_path_attached: a_path /= Void req_attached: req /= Void a_router_attached: a_router /= Void deferred end - try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER) - -- Try using `Current' mapping and if it matches request `req' + try (a_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER) + -- Try using `Current' mapping and if it matches path `a_path' and request `req' -- execute associated handler and set this handler in session `sess'. require + a_path_attached: a_path /= Void req_attached: req /= Void res_attached: res /= Void sess_attached: sess /= Void @@ -75,20 +77,8 @@ feature -- Status deferred end -feature -- Helper - - path_from_request (req: WSF_REQUEST): READABLE_STRING_8 - -- Path used by `Current' to check that mapping matches request `req' - require - req_attached: req /= Void - do - Result := req.percent_encoded_path_info - ensure - path_from_request_attached: Result /= Void - end - note - copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software