Added WSF_ROUTER.pre_route_execution_actions: ACTION_SEQUENCE [like route]
This way, one can add logger hook to router, to see which "route" was taken by the request.
This commit is contained in:
@@ -13,6 +13,7 @@ inherit
|
|||||||
redefine
|
redefine
|
||||||
map_agent_with_request_methods, map_agent_response_with_request_methods
|
map_agent_with_request_methods, map_agent_response_with_request_methods
|
||||||
end
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ feature -- Initialization
|
|||||||
do
|
do
|
||||||
create handlers.make (n)
|
create handlers.make (n)
|
||||||
handlers.compare_objects
|
handlers.compare_objects
|
||||||
|
initialize
|
||||||
end
|
end
|
||||||
|
|
||||||
make_with_base_url (n: INTEGER; a_base_url: like base_url)
|
make_with_base_url (n: INTEGER; a_base_url: like base_url)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ feature -- Initialization
|
|||||||
create handlers.make (n)
|
create handlers.make (n)
|
||||||
create templates.make (n)
|
create templates.make (n)
|
||||||
handlers.compare_objects
|
handlers.compare_objects
|
||||||
|
initialize
|
||||||
end
|
end
|
||||||
|
|
||||||
make_with_base_url (n: INTEGER; a_base_url: like base_url)
|
make_with_base_url (n: INTEGER; a_base_url: like base_url)
|
||||||
|
|||||||
@@ -36,11 +36,10 @@ feature -- Setup
|
|||||||
feature -- Execution
|
feature -- Execution
|
||||||
|
|
||||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
local
|
|
||||||
l_handled: BOOLEAN
|
|
||||||
do
|
do
|
||||||
l_handled := router.dispatch (req, res)
|
if attached router.route (req) as r then
|
||||||
if not l_handled then
|
router.execute_route (r, req, res)
|
||||||
|
else
|
||||||
execute_default (req, res)
|
execute_default (req, res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ deferred class
|
|||||||
inherit
|
inherit
|
||||||
ITERABLE [TUPLE [handler: H; resource: READABLE_STRING_8; request_methods: detachable ARRAY [READABLE_STRING_8]]]
|
ITERABLE [TUPLE [handler: H; resource: READABLE_STRING_8; request_methods: detachable ARRAY [READABLE_STRING_8]]]
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
initialize
|
||||||
|
-- Initialize router
|
||||||
|
do
|
||||||
|
create pre_route_execution_actions
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Status report
|
feature -- Status report
|
||||||
|
|
||||||
has_map (a_resource: READABLE_STRING_8; rqst_methods: detachable ARRAY [READABLE_STRING_8]; a_handler: detachable H): BOOLEAN
|
has_map (a_resource: READABLE_STRING_8; rqst_methods: detachable ARRAY [READABLE_STRING_8]; a_handler: detachable H): BOOLEAN
|
||||||
@@ -116,7 +124,13 @@ feature -- Element change
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Execution
|
feature -- Hook
|
||||||
|
|
||||||
|
pre_route_execution_actions: ACTION_SEQUENCE [TUPLE [like route]]
|
||||||
|
-- Action triggered before a route is execute
|
||||||
|
--| Could be used for tracing, logging
|
||||||
|
|
||||||
|
feature -- Routing
|
||||||
|
|
||||||
route (req: WSF_REQUEST): detachable WSF_ROUTE [H, C]
|
route (req: WSF_REQUEST): detachable WSF_ROUTE [H, C]
|
||||||
-- Route matching `req'.
|
-- Route matching `req'.
|
||||||
@@ -124,11 +138,14 @@ feature -- Execution
|
|||||||
Result := matching_route (req)
|
Result := matching_route (req)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Execution
|
||||||
|
|
||||||
execute_route (a_route: WSF_ROUTE [H,C]; req: WSF_REQUEST; res: WSF_RESPONSE)
|
execute_route (a_route: WSF_ROUTE [H,C]; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
-- Process route `a_route'
|
-- Process route `a_route'
|
||||||
require
|
require
|
||||||
a_route_attached: a_route /= Void
|
a_route_attached: a_route /= Void
|
||||||
do
|
do
|
||||||
|
pre_route_execution_actions.call ([a_route])
|
||||||
a_route.handler.execute (a_route.context, req, res)
|
a_route.handler.execute (a_route.context, req, res)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
deferred class
|
deferred class
|
||||||
WSF_ROUTING_HANDLER [H -> WSF_HANDLER [C],
|
WSF_ROUTING_HANDLER [H -> WSF_HANDLER [C], C -> WSF_HANDLER_CONTEXT]
|
||||||
C -> WSF_HANDLER_CONTEXT]
|
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_HANDLER [C]
|
WSF_HANDLER [C]
|
||||||
|
|||||||
Reference in New Issue
Block a user