fix merge conflict from master

This commit is contained in:
Colin Adams
2013-03-21 15:55:14 +00:00
72 changed files with 894 additions and 183 deletions

View File

@@ -1,41 +0,0 @@
note
description: "Summary description for {WSF_AGENT_CONTEXT_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_AGENT_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_CONTEXT_HANDLER [C]
feature -- Change
set_action (a_action: like action)
do
action := a_action
end
feature -- Access
action: PROCEDURE [ANY, TUPLE [context: C; request: WSF_REQUEST; response: WSF_RESPONSE]]
feature -- Execution
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
action.call ([ctx, req, res])
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,29 +0,0 @@
note
description: "Summary description for {WSF_CONTEXT_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_HANDLER
feature -- Execution
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
deferred
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,42 +0,0 @@
note
description: "Summary description for {WSF_FILTER_CONTEXT_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_FILTER_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_FILTER_HANDLER
redefine
next
end
WSF_CONTEXT_HANDLER [C]
feature -- Access
next: detachable WSF_CONTEXT_HANDLER [C]
-- Next handler
feature {NONE} -- Implementation
execute_next (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
if attached next as n then
n.execute (ctx, req, res)
end
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,43 +0,0 @@
note
description: "[
Context for the handler execution
It provides information related to the matching handler at runtime, i.e:
- request: WSF_REQUEST -- Associated request
- path: READABLE_STRING_8 -- Associated path
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_HANDLER_CONTEXT
create
make
feature {NONE} -- Initialization
make (req: like request; map: like mapping)
do
request := req
mapping := map
end
feature -- Access
request: WSF_REQUEST
-- Associated request
mapping: WSF_ROUTER_MAPPING
-- Associated mapping
;note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,41 +0,0 @@
note
description: "Summary description for {WSF_ROUTER_CONTEXT_MAPPING}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_ROUTER_CONTEXT_MAPPING [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_ROUTER_MAPPING
redefine
debug_output
end
feature -- Access
handler: WSF_CONTEXT_HANDLER [C]
-- Handler associated with Current mapping.
deferred
end
feature -- Status report
debug_output: STRING
-- String that should be displayed in debugger to represent `Current'.
do
Result := Precursor + " {" + ({C}).name + "}"
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,38 +0,0 @@
note
description: "Routing handler with context support"
author: "$Author$"
revision: "$Revision$"
class
WSF_ROUTING_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_ROUTING_HANDLER
WSF_CONTEXT_HANDLER [C]
rename
execute as execute_with_context
end
create
make,
make_with_router
feature -- Execution
execute_with_context (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
execute (req, res)
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -0,0 +1,37 @@
note
description: "Cross-Origin Resource Sharing filter."
author: "Olivier Ligot"
date: "$Date$"
revision: "$Revision$"
EIS: "name=Cross-Origin Resource Sharing", "src=http://www.w3.org/TR/cors/", "tag=W3C"
class
WSF_CORS_FILTER
inherit
WSF_FILTER
feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the filter.
local
l_header: HTTP_HEADER
do
create l_header.make
l_header.put_access_control_allow_all_origin
res.put_header_text (l_header.string)
execute_next (req, res)
end
note
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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -0,0 +1,57 @@
note
description: "Filter that handles an OPTIONS request, with Cross-Origin Resource Sharing support."
author: "Olvier Ligot"
date: "$Date$"
revision: "$Revision$"
EIS: "name=Cross-Origin Resource Sharing", "src=http://www.w3.org/TR/cors/", "tag=W3C"
class
WSF_CORS_OPTIONS_FILTER
inherit
WSF_FILTER
create
make
feature {NONE} -- Initialization
make (a_router: like router)
-- Initialize Current with `a_router'.
do
router := a_router
ensure
router_set: router = a_router
end
feature -- Access
router: WSF_ROUTER
-- Associated router
feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the filter.
local
msg: WSF_CORS_OPTIONS_RESPONSE
do
if req.is_request_method ({HTTP_REQUEST_METHODS}.method_options) then
create msg.make (req, router)
res.send (msg)
else
execute_next (req, res)
end
end
note
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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -14,7 +14,7 @@ feature -- Access
feature -- Element change
set_next (a_next: WSF_FILTER)
set_next (a_next: like next)
-- Set `next' to `a_next'
do
next := a_next
@@ -26,6 +26,9 @@ feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the filter.
require
req_attached: req /= Void
res_attached: res /= Void
deferred
end
@@ -33,6 +36,9 @@ feature {NONE} -- Implementation
execute_next (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the `next' filter.
require
req_attached: req /= Void
res_attached: res /= Void
do
if attached next as n then
n.execute (req, res)
@@ -40,7 +46,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

View File

@@ -8,14 +8,14 @@ note
revision: "$Revision$"
deferred class
WSF_FILTER_HANDLER
WSF_FILTER_HANDLER [G -> WSF_HANDLER]
inherit
WSF_HANDLER
feature -- Access
next: detachable WSF_HANDLER
next: detachable G
-- Next handler
feature -- Element change
@@ -29,7 +29,7 @@ feature -- Element change
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

View File

@@ -35,8 +35,15 @@ feature -- Access
filter: WSF_FILTER
-- Filter
feature -- Execution
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
do
filter.execute (req, res)
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

View File

@@ -0,0 +1,53 @@
note
description: "[
Handler wrapping a filter
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_HANDLER_FILTER_WRAPPER
inherit
WSF_HANDLER
create
make_with_filter
feature {NONE} -- Initialization
make_with_filter (f: WSF_FILTER)
-- Build Current with `f'.
require
f_attached: f /= Void
do
filter := f
ensure
filter_set: filter = f
end
feature -- Access
filter: WSF_FILTER
-- Associated filter.
feature -- Execution
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute handler for `req' and respond in `res'
-- by passing through filter `filter'
do
filter.execute (req, res)
end
note
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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -44,10 +44,12 @@ feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the filter
local
sess: WSF_ROUTER_SESSION
do
if attached router.dispatch_and_return_handler (req, res) then
check router.is_dispatched end
else
create sess
router.dispatch (req, res, sess)
if not sess.dispatched then
execute_default (req, res)
end
execute_next (req, res)
@@ -63,7 +65,7 @@ feature -- Basic operations
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

View File

@@ -1,45 +0,0 @@
note
description: "Summary description for {WSF_STARTS_WITH_AGENT_CONTEXT_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_STARTS_WITH_AGENT_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_STARTS_WITH_CONTEXT_HANDLER [C]
create
make
feature -- Change
make (a_action: like action)
do
action := a_action
end
feature -- Access
action: PROCEDURE [ANY, TUPLE [start_path: READABLE_STRING_8; context: C; request: WSF_REQUEST; response: WSF_RESPONSE]]
feature -- Execution
execute (a_start_path: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
action.call ([a_start_path, ctx, req, res])
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,47 +0,0 @@
note
description: "Summary description for {WSF_STARTS_WITH_CONTEXT_ROUTED_SERVICE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_STARTS_WITH_CONTEXT_ROUTED_SERVICE [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_ROUTED_SERVICE
feature -- Mapping helper: starts_with
map_starts_with (a_uri: READABLE_STRING_8; h: WSF_STARTS_WITH_CONTEXT_HANDLER [C])
do
map_starts_with_request_methods (a_uri, h, Void)
end
map_starts_with_request_methods (a_uri: READABLE_STRING_8; h: WSF_STARTS_WITH_CONTEXT_HANDLER [C]; rqst_methods: detachable WSF_REQUEST_METHODS)
do
router.map_with_request_methods (create {WSF_STARTS_WITH_CONTEXT_MAPPING [C]}.make (a_uri, h), rqst_methods)
end
feature -- Mapping helper: starts_with agent
map_starts_with_agent (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [start_path: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]])
do
map_starts_with_agent_with_request_methods (a_uri, proc, Void)
end
map_starts_with_agent_with_request_methods (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [start_path: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
do
map_starts_with_request_methods (a_uri, create {WSF_STARTS_WITH_AGENT_CONTEXT_HANDLER [C] }.make (proc), rqst_methods)
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,39 +0,0 @@
note
description: "Summary description for {WSF_STARTS_WITH_ROUTING_CONTEXT_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_STARTS_WITH_ROUTING_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_ROUTING_HANDLER
WSF_STARTS_WITH_CONTEXT_HANDLER [C]
rename
execute as execute_with_context
end
create
make,
make_with_router
feature -- Execution
execute_with_context (a_start_path: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
execute (req, res)
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -8,18 +8,10 @@ deferred class
WSF_STARTS_WITH_FILTER_HANDLER
inherit
WSF_FILTER_HANDLER
redefine
next
end
WSF_FILTER_HANDLER [WSF_STARTS_WITH_HANDLER]
WSF_STARTS_WITH_HANDLER
feature -- Access
next: detachable WSF_STARTS_WITH_FILTER_HANDLER
-- Next handler
feature -- Execution
execute_next (a_start_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -30,7 +22,7 @@ feature -- Execution
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

View File

@@ -1,38 +0,0 @@
note
description: "Summary description for {WSF_STARTS_WITH_CONTEXT_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_STARTS_WITH_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_HANDLER
WSF_ROUTER_MAPPING_FACTORY
feature -- Execution
execute (a_start_path: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
deferred
end
feature {WSF_ROUTER} -- Mapping
new_mapping (a_uri: READABLE_STRING_8): WSF_ROUTER_MAPPING
do
create {WSF_STARTS_WITH_CONTEXT_MAPPING [C]} Result.make (a_uri, Current)
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,64 +0,0 @@
note
description: "Summary description for WSF_STARTS_WITH_CONTEXT_MAPPING."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_STARTS_WITH_CONTEXT_MAPPING [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_STARTS_WITH_MAPPING_I
undefine
debug_output
end
WSF_ROUTER_MAPPING
redefine
debug_output
end
create
make
feature -- Access
handler: WSF_STARTS_WITH_CONTEXT_HANDLER [C]
feature -- change
set_handler (h: like handler)
do
handler := h
end
feature {NONE} -- Execution
execute_handler (h: like handler; a_start_path: like uri; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute handler `h' with `req' and `res' for Current mapping
local
ctx: C
do
create ctx.make (req, Current)
h.execute (a_start_path, ctx, req, res)
end
feature -- Status report
debug_output: STRING
-- String that should be displayed in debugger to represent `Current'.
do
Result := Precursor + " {" + ({C}).name + "}"
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -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

View File

@@ -1,31 +0,0 @@
note
description: "Summary description for {WSF_URI_AGENT_CONTEXT_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_URI_AGENT_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_URI_CONTEXT_HANDLER [C]
WSF_AGENT_CONTEXT_HANDLER [C]
rename
set_action as make
end
create
make
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,43 +0,0 @@
note
description: "Summary description for {WSF_URI_ROUTING_CONTEXT_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_URI_ROUTING_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_ROUTING_CONTEXT_HANDLER [C]
WSF_URI_CONTEXT_HANDLER [C]
rename
execute as uri_execute
select
uri_execute
end
create
make,
make_with_router
feature -- Execution
uri_execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- <Precursor>
--| For such routing handler, the previous context is lost
do
execute_with_context (ctx, req, res)
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -20,6 +20,8 @@ feature {NONE} -- Initialization
action := a_action
end
feature -- Access
action: PROCEDURE [ANY, TUPLE [request: WSF_REQUEST; response: WSF_RESPONSE]]
feature -- Execution
@@ -30,7 +32,7 @@ feature -- Execution
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

View File

@@ -8,18 +8,10 @@ deferred class
WSF_URI_FILTER_HANDLER
inherit
WSF_FILTER_HANDLER
redefine
next
end
WSF_FILTER_HANDLER [WSF_URI_HANDLER]
WSF_URI_HANDLER
feature -- Access
next: detachable WSF_URI_FILTER_HANDLER
-- Next handler
feature -- Execution
execute_next (req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -30,7 +22,7 @@ feature -- Execution
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

View File

@@ -7,35 +7,15 @@ note
deferred class
WSF_URI_ROUTED_SERVICE
obsolete "Inherit from WSF_ROUTED_SERVICE and WSF_URI_ROUTER_HELPER [2013-mar-19]"
inherit
WSF_ROUTED_SERVICE
feature -- Mapping helper: uri
map_uri (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER)
do
map_uri_with_request_methods (a_uri, h, Void)
end
map_uri_with_request_methods (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS)
do
router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, h), rqst_methods)
end
feature -- Mapping helper: uri agent
map_uri_agent (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]])
do
map_uri_agent_with_request_methods (a_uri, proc, Void)
end
map_uri_agent_with_request_methods (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
do
map_uri_with_request_methods (a_uri, create {WSF_URI_AGENT_HANDLER}.make (proc), rqst_methods)
end
WSF_URI_ROUTER_HELPER
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

View File

@@ -1,37 +1,40 @@
note
description: "Summary description for {WSF_URI_CONTEXT_ROUTED_SERVICE}."
description: "Summary description for {WSF_URI_ROUTER_HELPER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_URI_CONTEXT_ROUTED_SERVICE [C -> WSF_HANDLER_CONTEXT create make end]
WSF_URI_ROUTER_HELPER
inherit
WSF_ROUTED_SERVICE
feature -- Access
router: WSF_ROUTER
deferred
end
feature -- Mapping helper: uri
map_uri (a_uri: READABLE_STRING_8; h: WSF_URI_CONTEXT_HANDLER [C])
map_uri (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER)
do
map_uri_with_request_methods (a_uri, h, Void)
end
map_uri_with_request_methods (a_uri: READABLE_STRING_8; h: WSF_URI_CONTEXT_HANDLER [C]; rqst_methods: detachable WSF_REQUEST_METHODS)
map_uri_with_request_methods (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS)
do
router.map_with_request_methods (create {WSF_URI_CONTEXT_MAPPING [C]}.make (a_uri, h), rqst_methods)
router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, h), rqst_methods)
end
feature -- Mapping helper: uri agent
map_uri_agent (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]])
map_uri_agent (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]])
do
map_uri_agent_with_request_methods (a_uri, proc, Void)
end
map_uri_agent_with_request_methods (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
map_uri_agent_with_request_methods (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
do
map_uri_with_request_methods (a_uri, create {WSF_URI_AGENT_CONTEXT_HANDLER [C] }.make (proc), rqst_methods)
map_uri_with_request_methods (a_uri, create {WSF_URI_AGENT_HANDLER}.make (proc), rqst_methods)
end
note

View File

@@ -1,32 +0,0 @@
note
description: "Summary description for {WSF_URI_CONTEXT_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_URI_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_CONTEXT_HANDLER [C]
WSF_ROUTER_MAPPING_FACTORY
feature {WSF_ROUTER} -- Mapping
new_mapping (a_uri: READABLE_STRING_8): WSF_ROUTER_MAPPING
do
create {WSF_URI_CONTEXT_MAPPING [C]} Result.make (a_uri, Current)
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,53 +0,0 @@
note
description: "Summary description for WSF_URI_CONTEXT_MAPPING."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_URI_CONTEXT_MAPPING [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_URI_MAPPING_I
undefine
debug_output
end
WSF_ROUTER_CONTEXT_MAPPING [C]
create
make,
make_trailing_slash_ignored
feature -- Access
handler: WSF_URI_CONTEXT_HANDLER [C]
feature -- Change
set_handler (h: like handler)
do
handler := h
end
feature {NONE} -- Execution
execute_handler (h: like handler; req: WSF_REQUEST; res: WSF_RESPONSE)
local
ctx: C
do
create ctx.make (req, Current)
h.execute (ctx, req, res)
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -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

View File

@@ -1,31 +0,0 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_AGENT_CONTEXT_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_URI_TEMPLATE_AGENT_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_URI_TEMPLATE_CONTEXT_HANDLER [C]
WSF_AGENT_CONTEXT_HANDLER [C]
rename
set_action as make
end
create
make
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,47 +0,0 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_CONTEXT_ROUTED_SERVICE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_URI_TEMPLATE_CONTEXT_ROUTED_SERVICE [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_ROUTED_SERVICE
feature -- Mapping helper: uri
map_uri_template (a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_CONTEXT_HANDLER [C])
do
map_uri_template_with_request_methods (a_tpl, h, Void)
end
map_uri_template_with_request_methods (a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_CONTEXT_HANDLER [C]; rqst_methods: detachable WSF_REQUEST_METHODS)
do
router.map_with_request_methods (create {WSF_URI_TEMPLATE_CONTEXT_MAPPING [C]}.make (a_tpl, h), rqst_methods)
end
feature -- Mapping helper: uri agent
map_uri_template_agent (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]])
do
map_uri_template_agent_with_request_methods (a_tpl, proc, Void)
end
map_uri_template_agent_with_request_methods (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
do
map_uri_template_with_request_methods (a_tpl, create {WSF_URI_TEMPLATE_AGENT_CONTEXT_HANDLER [C] }.make (proc), rqst_methods)
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,42 +0,0 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_FILTER_CONTEXT_HANDLER}."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
deferred class
WSF_URI_TEMPLATE_FILTER_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_FILTER_HANDLER
redefine
next
end
WSF_URI_TEMPLATE_CONTEXT_HANDLER [C]
feature -- Access
next: detachable WSF_URI_TEMPLATE_CONTEXT_HANDLER [C]
-- Next handler
feature -- Execution
execute_next (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
if attached next as n then
n.execute (ctx, req, res)
end
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,43 +0,0 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_ROUTING_CONTEXT_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_URI_TEMPLATE_ROUTING_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_ROUTING_CONTEXT_HANDLER [C]
WSF_URI_TEMPLATE_CONTEXT_HANDLER [C]
rename
execute as uri_template_execute
select
uri_template_execute
end
create
make,
make_with_router
feature -- Execution
uri_template_execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- <Precursor>
--| For such routing handler, the previous context is lost
do
execute_with_context (ctx, req, res)
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -20,6 +20,8 @@ feature {NONE} -- Initialization
action := a_action
end
feature -- Access
action: PROCEDURE [ANY, TUPLE [request: WSF_REQUEST; response: WSF_RESPONSE]]
feature -- Execution
@@ -30,7 +32,7 @@ feature -- Execution
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

View File

@@ -8,18 +8,10 @@ deferred class
WSF_URI_TEMPLATE_FILTER_HANDLER
inherit
WSF_FILTER_HANDLER
redefine
next
end
WSF_FILTER_HANDLER [WSF_URI_TEMPLATE_HANDLER]
WSF_URI_TEMPLATE_HANDLER
feature -- Access
next: detachable WSF_URI_TEMPLATE_HANDLER
-- Next handler
feature -- Execution
execute_next (req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -30,7 +22,7 @@ feature -- Execution
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

View File

@@ -6,11 +6,14 @@ note
deferred class WSF_URI_TEMPLATE_ROUTED_SERVICE
obsolete "Inherit from WSF_ROUTED_SERVICE and WSF_URI_ROUTER_HELPER [2013-mar-19]"
inherit
WSF_ROUTED_SERVICE
WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_SERVICE
WSF_URI_TEMPLATE_ROUTER_HELPER
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"

View File

@@ -0,0 +1,66 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_ROUTER_HELPER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_URI_TEMPLATE_ROUTER_HELPER
feature -- Access
router: WSF_ROUTER
deferred
end
feature -- Mapping helper: uri
map_uri_template (a_tpl: STRING; h: WSF_URI_TEMPLATE_HANDLER)
-- Map `h' as handler for `a_tpl'
require
a_tpl_attached: a_tpl /= Void
h_attached: h /= Void
do
map_uri_template_with_request_methods (a_tpl, h, Void)
end
map_uri_template_with_request_methods (a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS)
-- Map `h' as handler for `a_tpl' for request methods `rqst_methods'.
require
a_tpl_attached: a_tpl /= Void
h_attached: h /= Void
do
router.map_with_request_methods (create {WSF_URI_TEMPLATE_MAPPING}.make (a_tpl, h), rqst_methods)
end
feature -- Mapping helper: uri agent
map_uri_template_agent (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]])
-- Map `proc' as handler for `a_tpl'
require
a_tpl_attached: a_tpl /= Void
proc_attached: proc /= Void
do
map_uri_template_agent_with_request_methods (a_tpl, proc, Void)
end
map_uri_template_agent_with_request_methods (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
-- Map `proc' as handler for `a_tpl' for request methods `rqst_methods'.
require
a_tpl_attached: a_tpl /= Void
proc_attached: proc /= Void
do
map_uri_template_with_request_methods (a_tpl, create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (proc), rqst_methods)
end
note
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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,32 +0,0 @@
note
description: "Summary description for WSF_URI_TEMPLATE_CONTEXT_HANDLER."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_URI_TEMPLATE_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_CONTEXT_HANDLER [C]
WSF_ROUTER_MAPPING_FACTORY
feature {WSF_ROUTER} -- Mapping
new_mapping (a_tpl: READABLE_STRING_8): WSF_ROUTER_MAPPING
do
create {WSF_URI_TEMPLATE_CONTEXT_MAPPING [C]} Result.make (a_tpl, Current)
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -1,53 +0,0 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_CONTEXT_MAPPING}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_URI_TEMPLATE_CONTEXT_MAPPING [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_URI_TEMPLATE_MAPPING_I
undefine
debug_output
end
WSF_ROUTER_CONTEXT_MAPPING [C]
create
make,
make_from_template
feature -- Access
handler: WSF_URI_TEMPLATE_CONTEXT_HANDLER [C]
feature -- Change
set_handler (h: like handler)
do
handler := h
end
feature {NONE} -- Execution
execute_handler (h: like handler; req: WSF_REQUEST; res: WSF_RESPONSE)
local
ctx: detachable C
do
create ctx.make (req, Current)
h.execute (ctx, req, res)
end
note
copyright: "2011-2012, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -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

View File

@@ -1,6 +1,7 @@
note
description: "Summary description for {WSF_HANDLER}."
author: ""
description: "[
Represents the ancestor of all the WSF_ROUTER handler.
]"
date: "$Date$"
revision: "$Revision$"
@@ -27,7 +28,7 @@ feature {WSF_ROUTER} -- Mapping
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

View File

@@ -40,10 +40,12 @@ feature -- Execution
require
req_attached: req /= Void
res_attached: res /= Void
local
sess: WSF_ROUTER_SESSION
do
if attached router.dispatch_and_return_handler (req, res) as p then
-- executed
else
create sess
router.dispatch (req, res, sess)
if not sess.dispatched then
execute_default (req, res)
end
ensure

View File

@@ -112,75 +112,84 @@ feature -- Mapping handler
map_with_request_methods (f.new_mapping (a_resource), rqst_methods)
end
feature -- Access
is_dispatched: BOOLEAN
-- `dispatch' set `is_dispatched' to True
-- if mapping was found, and associated handler executed
feature -- Basic operations
dispatch (req: WSF_REQUEST; res: WSF_RESPONSE)
dispatch (req: WSF_REQUEST; res: WSF_RESPONSE; sess: detachable WSF_ROUTER_SESSION)
-- Dispatch request `req' among the `mappings'.
-- Set `is_dispatched' if the request were dispatched.
-- Set `sess' if the request were dispatched and `sess' attached.
require
req_attached: req /= Void
res_attached: res /= Void
local
l_sess: detachable WSF_ROUTER_SESSION
do
if attached dispatch_and_return_handler (req, res) then
check is_dispatched: is_dispatched end
l_sess := sess
if l_sess = Void then
create l_sess
end
router_dispatch (req, res, l_sess)
end
dispatch_and_return_handler (req: WSF_REQUEST; res: WSF_RESPONSE): detachable WSF_HANDLER
-- Dispatch request `req' among the `mappings'
-- And return the associated handler if mapping found and handler executed.
--| Violates CQS
obsolete
"Use `dispatch' [2013-mar-21]"
require
req_attached: req /= Void
res_attached: res /= Void
local
sess: WSF_ROUTER_SESSION
do
create sess
router_dispatch (req, res, sess)
Result := sess.dispatched_handler
end
feature {NONE} -- Dispatch implementation
router_dispatch (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION)
require
req_attached: req /= Void
res_attached: res /= Void
sess_attached: sess /= Void
sess_not_dispatched: not sess.dispatched
local
l_req_method: READABLE_STRING_8
head_res: WSF_HEAD_RESPONSE_WRAPPER
do
l_req_method := request_method (req)
is_dispatched := False
Result := dispatch_and_return_handler_for_request_method (req, res, l_req_method)
if Result = Void and l_req_method = {HTTP_REQUEST_METHODS}.method_head then
check is_not_dispatched: not is_dispatched end
router_dispatch_for_request_method (req, res, sess, l_req_method)
if not sess.dispatched and l_req_method = {HTTP_REQUEST_METHODS}.method_head then
create head_res.make_from_response (res)
req.set_request_method ({HTTP_REQUEST_METHODS}.method_GET)
Result := dispatch_and_return_handler_for_request_method (req, head_res, {HTTP_REQUEST_METHODS}.method_GET)
router_dispatch_for_request_method (req, head_res, sess, {HTTP_REQUEST_METHODS}.method_GET)
end
end
feature {NONE} -- Dispatch implementation
dispatch_and_return_handler_for_request_method (req: WSF_REQUEST; res: WSF_RESPONSE; a_request_method: READABLE_STRING_8): detachable WSF_HANDLER
router_dispatch_for_request_method (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_request_method: READABLE_STRING_8)
-- Dispatch request `req' among the `mappings'
-- And return the associated handler if mapping found and handler executed.
--| Violates CQS
require
req_attached: req /= Void
res_attached: res /= Void
sess_attached: sess /= Void
sess_not_dispatched: not sess.dispatched
a_request_method_attached: a_request_method /= Void
local
m: WSF_ROUTER_MAPPING
do
is_dispatched := False
across
mappings as c
until
Result /= Void
sess.dispatched
loop
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
if attached m.routed_handler (req, res, Current) as r then
is_dispatched := True
Result := r
end
m.try (req, res, sess, Current)
end
end
end

View File

@@ -1,6 +1,7 @@
note
description: "Summary description for {WSF_ROUTER_MAPPING}."
author: ""
description: "[
Describes a route or mapping for the WSF_ROUTER
]"
date: "$Date$"
revision: "$Revision$"
@@ -23,14 +24,14 @@ feature {NONE} -- Initialization
feature -- Access
associated_resource: READABLE_STRING_8
-- Name (URI, or URI template or regular expression or ...) of handled resource
-- Name (URI, or URI template or regular expression or ...) of handled resource.
deferred
ensure
assciated_resource_not_void: Result /= Void
end
handler: WSF_HANDLER
-- Handler associated with `Current' mapping
-- Handler associated with `Current' mapping.
deferred
ensure
handler_attached: Result /= Void
@@ -39,7 +40,7 @@ feature -- Access
feature -- Documentation
description: READABLE_STRING_32
-- Short description of associated mapping
-- Short description of associated mapping.
deferred
ensure
description_attached: Result /= Void
@@ -63,11 +64,13 @@ feature -- Status
deferred
end
routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER
-- Handler when `Current' matches the request `req'
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'
-- execute associated handler and set this handler in session `sess'.
require
req_attached: req /= Void
res_attached: res /= Void
sess_attached: sess /= Void
a_router_attached: a_router /= Void
deferred
end
@@ -75,7 +78,7 @@ feature -- Status
feature -- Helper
path_from_request (req: WSF_REQUEST): READABLE_STRING_32
-- Path used by `Current' to check that mapping matches request `req'
-- Path used by `Current' to check that mapping matches request `req'.
require
req_attached: req /= Void
do

View File

@@ -0,0 +1,46 @@
note
description: "[
This class represents the processing of a request via a WSF_ROUTER.
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_ROUTER_SESSION
feature -- Status report
dispatched: BOOLEAN
-- Handler dispatched?
do
Result := dispatched_handler /= Void
ensure
Result implies dispatched_handler /= Void
end
feature -- Access
dispatched_handler: detachable WSF_HANDLER
-- Handler dispatched
feature -- Change
set_dispatched_handler (h: like dispatched_handler)
do
dispatched_handler := h
ensure
h_set: dispatched_handler = h
end
note
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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -54,16 +54,18 @@ feature -- Execution
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
local
sess: WSF_ROUTER_SESSION
do
if attached router.dispatch_and_return_handler (req, res) as h then
check is_dispatched: router.is_dispatched end
else
create sess
router.dispatch (req, res, sess)
if not sess.dispatched then
res.put_header ({HTTP_STATUS_CODE}.not_found, <<[{HTTP_HEADER_NAMES}.header_content_length, "0"]>>)
end
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