Further changes in response to review comments by Jocelyn

This commit is contained in:
Colin Adams
2013-03-27 15:38:13 +00:00
parent 4875ca9ff1
commit 5249275b23
4 changed files with 128 additions and 27 deletions

View File

@@ -0,0 +1,27 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_ROUTED_SERVICE}."
author: ""
date: "$Date$"
revision: "$Revision$"
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_ROUTER_HELPER
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,68 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_ROUTER_HELPER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_URI_TEMPLATE_ROUTER_HELPER
obsolete "Use class WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_SERVICE in conjunction with WSF_ROUTED_SKELETON_SERVICE"
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

@@ -22,6 +22,8 @@ feature -- Execution
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- If the service is available, and request URI is not too long, dispatch the request
-- and if handler is not found, execute the default procedure `execute_default'.
local
l_sess: WSF_ROUTER_SESSION
do
--| When we reach here, the request has already passed check for 400 (Bad request),
--| which is implemented in WSF_REQUEST.make_from_wgi (when it calls `analyze').
@@ -34,10 +36,12 @@ feature -- Execution
elseif req.is_request_method ({HTTP_REQUEST_METHODS}.method_options) and then
req.request_uri.same_string ("*") then
handle_server_options (req, res)
elseif attached router.dispatch_and_return_handler (req, res) as p then
-- executed
else
execute_default (req, res)
create l_sess
router.dispatch (req, res, l_sess)
if not l_sess.dispatched then
execute_default (req, res)
end
end
end
@@ -180,7 +184,7 @@ feature {NONE} -- Implementation
frozen handle_system_options_forbidden (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Write a 403 Forbidden or a 404 Not found response into `res'.
require
require
req_attached: req /= Void
res_attached: res /= Void
method_is_options: req.is_request_method ({HTTP_REQUEST_METHODS}.method_options)
@@ -217,7 +221,7 @@ feature {NONE} -- Implementation
handle_system_options (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Write response to OPTIONS * into `res'.
-- This may be redefined by the user, but normally this will not be necessary.
require
require
req_attached: req /= Void
res_attached: res /= Void
method_is_options: req.is_request_method ({HTTP_REQUEST_METHODS}.method_options)