Introduced WSF_ROUTER_SESSION
This fixes CQS violation from WSF_ROUTER.dispatch_and_return_handler (...): ? WSF_HANDLER and related code, and this is more compliant with concurrency. In addition, the WSF_ROUTER_SESSION can be enhanced in the future to answer more advanced needs.
This commit is contained in:
@@ -58,7 +58,7 @@ feature -- Status
|
||||
Result := p.starts_with (s)
|
||||
end
|
||||
|
||||
routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER
|
||||
try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER)
|
||||
-- Return the handler if Current matches the request `req'.
|
||||
local
|
||||
p: READABLE_STRING_8
|
||||
@@ -67,7 +67,7 @@ feature -- Status
|
||||
p := path_from_request (req)
|
||||
s := based_uri (uri, a_router)
|
||||
if p.starts_with (s) then
|
||||
Result := handler
|
||||
sess.set_dispatched_handler (handler)
|
||||
a_router.execute_before (Current)
|
||||
execute_handler (handler, s, req, res)
|
||||
a_router.execute_after (Current)
|
||||
@@ -113,7 +113,7 @@ invariant
|
||||
uri_attached: uri /= Void
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -72,10 +72,10 @@ feature -- Status
|
||||
end
|
||||
end
|
||||
|
||||
routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER
|
||||
try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER)
|
||||
do
|
||||
if is_mapping (req, a_router) then
|
||||
Result := handler
|
||||
sess.set_dispatched_handler (handler)
|
||||
a_router.execute_before (Current)
|
||||
execute_handler (handler, req, res)
|
||||
a_router.execute_after (Current)
|
||||
@@ -105,7 +105,7 @@ feature {NONE} -- Implementation
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -24,7 +24,7 @@ feature {NONE} -- Initialization
|
||||
-- Create with `h' as the handler for resources matching `tpl'
|
||||
require
|
||||
tpl_attached: tpl /= Void
|
||||
h_attached: h /= Void
|
||||
h_attached: h /= Void
|
||||
do
|
||||
template := tpl
|
||||
set_handler (h)
|
||||
@@ -68,7 +68,7 @@ feature -- Status
|
||||
Result := tpl.match (p) /= Void
|
||||
end
|
||||
|
||||
routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER
|
||||
try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER)
|
||||
-- <Precursor>
|
||||
local
|
||||
tpl: URI_TEMPLATE
|
||||
@@ -78,7 +78,7 @@ feature -- Status
|
||||
p := path_from_request (req)
|
||||
tpl := based_uri_template (template, a_router)
|
||||
if attached tpl.match (p) as tpl_res then
|
||||
Result := handler
|
||||
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
|
||||
@@ -126,7 +126,7 @@ feature {NONE} -- Implementation
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
Reference in New Issue
Block a user