Added notion of mapping factory, so one can implement a handler without having to implement new_mapping
Added filter context handler Added WSF_STARTS_WITH_ROUTING_HANDLER and WSF_URI_ROUTING_HANDLER (in addition to the uri template version)
This commit is contained in:
@@ -16,13 +16,6 @@ feature -- Execution
|
||||
deferred
|
||||
end
|
||||
|
||||
feature {WSF_ROUTER} -- Mapping
|
||||
|
||||
new_mapping (a_resource: READABLE_STRING_8): WSF_ROUTER_MAPPING
|
||||
-- New mapping built with Current as handler
|
||||
deferred
|
||||
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)"
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
note
|
||||
description: "Summary description for {WSF_STARTS_WITH_ROUTING_HANDLER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_STARTS_WITH_ROUTING_HANDLER
|
||||
|
||||
inherit
|
||||
WSF_ROUTING_HANDLER
|
||||
|
||||
WSF_STARTS_WITH_HANDLER
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_router
|
||||
|
||||
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)"
|
||||
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
|
||||
@@ -10,6 +10,8 @@ deferred class
|
||||
inherit
|
||||
WSF_HANDLER
|
||||
|
||||
WSF_ROUTER_MAPPING_FACTORY
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (a_start_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
note
|
||||
description: "Summary description for {WSF_URI_ROUTING_HANDLER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_URI_ROUTING_HANDLER
|
||||
|
||||
inherit
|
||||
WSF_ROUTING_HANDLER
|
||||
|
||||
WSF_URI_HANDLER
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_router
|
||||
|
||||
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)"
|
||||
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
|
||||
@@ -10,6 +10,8 @@ deferred class
|
||||
inherit
|
||||
WSF_HANDLER
|
||||
|
||||
WSF_ROUTER_MAPPING_FACTORY
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
|
||||
@@ -10,6 +10,8 @@ deferred class
|
||||
inherit
|
||||
WSF_HANDLER
|
||||
|
||||
WSF_ROUTER_MAPPING_FACTORY
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
|
||||
@@ -10,6 +10,8 @@ deferred class
|
||||
inherit
|
||||
WSF_CONTEXT_HANDLER [C]
|
||||
|
||||
WSF_ROUTER_MAPPING_FACTORY
|
||||
|
||||
feature {WSF_ROUTER} -- Mapping
|
||||
|
||||
new_mapping (a_tpl: READABLE_STRING_8): WSF_ROUTER_MAPPING
|
||||
|
||||
@@ -17,14 +17,7 @@ feature -- Status report
|
||||
|
||||
feature {WSF_ROUTER} -- Mapping
|
||||
|
||||
new_mapping (a_resource: READABLE_STRING_8): WSF_ROUTER_MAPPING
|
||||
-- New mapping built with Current as handler
|
||||
deferred
|
||||
ensure
|
||||
Result /= Void and then Result.handler = Current
|
||||
end
|
||||
|
||||
on_mapped (a_mapping: like new_mapping; a_rqst_methods: detachable WSF_ROUTER_METHODS)
|
||||
on_mapped (a_mapping: WSF_ROUTER_MAPPING; a_rqst_methods: detachable WSF_ROUTER_METHODS)
|
||||
-- Callback called when a router map a route to Current handler
|
||||
do
|
||||
end
|
||||
|
||||
@@ -59,17 +59,17 @@ feature -- Mapping
|
||||
|
||||
feature -- Mapping handler
|
||||
|
||||
handle (a_resource: READABLE_STRING_8; h: WSF_HANDLER)
|
||||
-- Map the mapping associated to handler `h' for resource `a_resource'
|
||||
handle (a_resource: READABLE_STRING_8; f: WSF_ROUTER_MAPPING_FACTORY)
|
||||
-- Map the mapping created by factory `f' for resource `a_resource'
|
||||
do
|
||||
handle_with_request_methods (a_resource, h, Void)
|
||||
handle_with_request_methods (a_resource, f, Void)
|
||||
end
|
||||
|
||||
handle_with_request_methods (a_resource: READABLE_STRING_8; h: WSF_HANDLER; rqst_methods: detachable WSF_ROUTER_METHODS)
|
||||
-- Map the mapping associated to handler `h' for resource `a_resource'
|
||||
handle_with_request_methods (a_resource: READABLE_STRING_8; f: WSF_ROUTER_MAPPING_FACTORY; rqst_methods: detachable WSF_ROUTER_METHODS)
|
||||
-- Map the mapping created by factory `f' for resource `a_resource'
|
||||
-- and only for request methods `rqst_methods'
|
||||
do
|
||||
map_with_request_methods (h.new_mapping (a_resource), rqst_methods)
|
||||
map_with_request_methods (f.new_mapping (a_resource), rqst_methods)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -220,6 +220,15 @@ feature -- Request methods helper
|
||||
Result.lock
|
||||
end
|
||||
|
||||
methods_get_put_delete: WSF_ROUTER_METHODS
|
||||
once ("THREAD")
|
||||
create Result.make (3)
|
||||
Result.enable_get
|
||||
Result.enable_put
|
||||
Result.enable_delete
|
||||
Result.lock
|
||||
end
|
||||
|
||||
methods_head_get: WSF_ROUTER_METHODS
|
||||
once ("THREAD")
|
||||
create Result.make (2)
|
||||
|
||||
32
library/server/wsf/router/wsf_router_mapping_factory.e
Normal file
32
library/server/wsf/router/wsf_router_mapping_factory.e
Normal file
@@ -0,0 +1,32 @@
|
||||
note
|
||||
description: "[
|
||||
Component that know how to create a router mapping from request and response.
|
||||
Usually handler inherits from this classes, this way, it is easy to use WSF_ROUTER.handle_... (resource, handler, ..)
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_ROUTER_MAPPING_FACTORY
|
||||
|
||||
feature {WSF_ROUTER} -- Mapping
|
||||
|
||||
new_mapping (a_uri: READABLE_STRING_8): WSF_ROUTER_MAPPING
|
||||
-- New mapping object
|
||||
deferred
|
||||
ensure
|
||||
Result_attached: Result /= Void
|
||||
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)"
|
||||
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
|
||||
34
library/server/wsf/src/filter/wsf_filter_context_handler.e
Normal file
34
library/server/wsf/src/filter/wsf_filter_context_handler.e
Normal file
@@ -0,0 +1,34 @@
|
||||
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, H -> WSF_CONTEXT_HANDLER [C]]
|
||||
|
||||
inherit
|
||||
WSF_FILTER_HANDLER [H]
|
||||
|
||||
WSF_CONTEXT_HANDLER [C]
|
||||
|
||||
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, 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
|
||||
Reference in New Issue
Block a user