Removed default handler for WSF_ROUTER

Added 	WSF_ROUTE to replace a TUPLE [H, C]
	WSF_ROUTER.route (req): detachable WSF_ROUTE
	WSF_ROUTER.execute_route (a_route, req, res)
	To help usage of Routers
Remove WSF_HANDLER_CONTEXT obsolete features.
Added comments
This commit is contained in:
Jocelyn Fiat
2012-04-05 21:13:04 +02:00
parent 593e48ec5b
commit 10ebc12852
14 changed files with 216 additions and 145 deletions

View File

@@ -1,6 +1,7 @@
note
description: "Summary description for {DEFAULT_REQUEST_URI_TEMPLATE_ROUTER}."
author: ""
description: "[
Default router based on URI Template map
]"
date: "$Date$"
revision: "$Revision$"

View File

@@ -1,6 +1,8 @@
note
description: "Summary description for {DEFAULT_REQUEST_URI_TEMPLATE_ROUTING_HANDLER}."
author: ""
description: "[
WSF_URI_TEMPLATE_ROUTING_HANDLER is a default descendant of WSF_URI_ROUTING_HANDLER_I
for WSF_URI_TEMPLATE_ROUTER
]"
date: "$Date$"
revision: "$Revision$"

View File

@@ -1,6 +1,17 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_HANDLER_CONTEXT}."
author: ""
description: "[
Context for the handler execution
The associated context {WSF_URI_TEMPLATE_HANDLER_CONTEXT} add information about the matched map
- uri_template : the associated URI_TEMPLATE
- uri_template_match : the matching result providing path variables
- additional path_parameter (..) and related queries
In addition to what WSF_HANDLER_CONTEXT already provides, i.e:
- request: WSF_REQUEST -- Associated request
- path: READABLE_STRING_8 -- Associated path
]"
date: "$Date$"
revision: "$Revision$"

View File

@@ -1,6 +1,16 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_ROUTER}."
author: ""
description: "[
URL dispatcher/router based on URI Template mapping and request methods if precised
The associated context {WSF_URI_TEMPLATE_HANDLER_CONTEXT} contains information about the matched map.
Examples:
map ("/users/", users_handler)
map_with_request_methods ("/order/{order-id}", order_handler, <<"GET", "POST">>)
map_agent_with_request_methods ("/order/{order-id}", agent do_get_order, <<"GET">>)
map_agent_with_request_methods ("/order/{order-id}", agent do_post_order, <<"POST">>)
]"
date: "$Date$"
revision: "$Revision$"
@@ -108,7 +118,7 @@ feature {NONE} -- Implementation
feature {WSF_ROUTED_SERVICE_I} -- Handler
handler (req: WSF_REQUEST): detachable TUPLE [handler: attached like default_handler; context: like default_handler_context]
matching_route (req: WSF_REQUEST): detachable WSF_ROUTE [H, C]
local
l_handlers: like handlers
t: READABLE_STRING_8
@@ -134,11 +144,11 @@ feature {WSF_ROUTED_SERVICE_I} -- Handler
create l_res.make_empty
l_res.path_variables.force (p.substring (t.count + 1, p.count), "path")
Result := [l_info.handler, handler_context (p, req, create {URI_TEMPLATE}.make (t), l_res)]
create Result.make (l_info.handler, handler_context (p, req, create {URI_TEMPLATE}.make (t), l_res))
elseif attached templates.item (t) as tpl and then
attached tpl.match (p) as res
then
Result := [l_info.handler, handler_context (p, req, tpl, res)]
create Result.make (l_info.handler, handler_context (p, req, tpl, res))
end
end
end
@@ -146,6 +156,14 @@ feature {WSF_ROUTED_SERVICE_I} -- Handler
end
end
feature {WSF_ROUTED_SERVICE_I} -- Default: implementation
default_handler_context (req: WSF_REQUEST): C
-- <Precursor>
do
Result := handler_context (Void, req, create {URI_TEMPLATE}.make ("/"), create {URI_TEMPLATE_MATCH_RESULT}.make_empty)
end
feature {NONE} -- Context factory
handler_context (p: detachable READABLE_STRING_8; req: WSF_REQUEST; tpl: URI_TEMPLATE; tpl_res: URI_TEMPLATE_MATCH_RESULT): C
@@ -196,20 +214,6 @@ feature {NONE} -- Implementation
result_not_empty: not Result.is_empty
end
feature {NONE} -- Default: implementation
default_handler: detachable H
set_default_handler (h: like default_handler)
do
default_handler := h
end
default_handler_context (req: WSF_REQUEST): C
do
Result := handler_context (Void, req, create {URI_TEMPLATE}.make ("/"), create {URI_TEMPLATE_MATCH_RESULT}.make_empty)
end
;note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -1,6 +1,7 @@
note
description: "Summary description for {WSF_ROUTING_HANDLER }."
author: ""
description: "[
This class helps to build Routing handler based for WSF_URI_TEMPLATE_ROUTER
]"
date: "$Date$"
revision: "$Revision$"