New ROUTER design, much simpler, less generic, easier to extend, and now one can mix uri map, uri_template map and so on.

Update the "tutorial" example.
This commit is contained in:
Jocelyn Fiat
2012-09-19 10:50:27 +02:00
parent 0f59535696
commit ace897ea2b
31 changed files with 668 additions and 1359 deletions
@@ -0,0 +1,19 @@
note
description: "Summary description for {WSF_STARTS_WITH_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_STARTS_WITH_HANDLER
inherit
WSF_HANDLER
feature -- Execution
execute (a_start_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE)
deferred
end
end
@@ -0,0 +1,62 @@
note
description: "Summary description for EWF_URI_PATH."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_STARTS_WITH_MAPPING
inherit
WSF_ROUTER_MAPPING
create
make
feature {NONE} -- Initialization
make (a_uri: READABLE_STRING_8; h: like handler)
do
handler := h
uri := a_uri
end
feature -- Access
handler: WSF_STARTS_WITH_HANDLER
uri: READABLE_STRING_8
feature -- Status
routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER
local
p: READABLE_STRING_8
s: like based_uri
do
p := source_uri (req)
s := based_uri (uri, a_router)
if p.starts_with (s) then
Result := handler
a_router.execute_before (Current)
handler.execute (s, req, res)
a_router.execute_after (Current)
end
end
feature {NONE} -- Implementation
based_uri (a_uri: like uri; a_router: WSF_ROUTER): like uri
local
s: STRING_8
do
if attached a_router.base_url as l_base_url then
create s.make_from_string (l_base_url)
s.append_string (a_uri)
Result := s
else
Result := a_uri
end
end
end