Reviewed the semantic of the handler context.
Adapted existing code to fit the new router design.
This commit is contained in:
@@ -38,7 +38,6 @@ feature {NONE} -- Initialization
|
||||
l_authentication_filter_hdl: AUTHENTICATION_FILTER
|
||||
l_user_filter: USER_HANDLER
|
||||
l_user_handler: WSF_URI_TEMPLATE_HANDLER
|
||||
-- l_routing_hdl: WSF_URI_TEMPLATE_ROUTING_HANDLER --[WSF_HANDLER [WSF_URI_TEMPLATE_HANDLER_CONTEXT], WSF_URI_TEMPLATE_HANDLER_CONTEXT]
|
||||
l_routing_filter: WSF_ROUTING_FILTER
|
||||
do
|
||||
create l_router.make (1)
|
||||
|
||||
@@ -42,9 +42,9 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Helper: mapping
|
||||
|
||||
map_agent_uri (a_uri: READABLE_STRING_8; a_action: like {WSF_AGENT_URI_HANDLER}.action; rqst_methods: detachable WSF_ROUTER_METHODS)
|
||||
map_agent_uri (a_uri: READABLE_STRING_8; a_action: like {WSF_URI_AGENT_HANDLER}.action; rqst_methods: detachable WSF_ROUTER_METHODS)
|
||||
do
|
||||
router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, create {WSF_AGENT_URI_HANDLER}.make (a_action)), rqst_methods)
|
||||
router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, create {WSF_URI_AGENT_HANDLER}.make (a_action)), rqst_methods)
|
||||
end
|
||||
|
||||
map_uri_template (a_tpl: READABLE_STRING_8; a_handler: WSF_URI_TEMPLATE_HANDLER; rqst_methods: detachable WSF_ROUTER_METHODS)
|
||||
@@ -52,9 +52,9 @@ feature -- Helper: mapping
|
||||
router.map_with_request_methods (create {WSF_URI_TEMPLATE_MAPPING}.make (a_tpl, a_handler), rqst_methods)
|
||||
end
|
||||
|
||||
map_agent_uri_template_response (a_tpl: READABLE_STRING_8; a_action: like {WSF_AGENT_URI_TEMPLATE_RESPONSE_HANDLER}.action; rqst_methods: detachable WSF_ROUTER_METHODS)
|
||||
map_agent_uri_template_response (a_tpl: READABLE_STRING_8; a_action: like {WSF_URI_TEMPLATE_RESPONSE_AGENT_HANDLER}.action; rqst_methods: detachable WSF_ROUTER_METHODS)
|
||||
do
|
||||
router.map_with_request_methods (create {WSF_URI_TEMPLATE_MAPPING}.make (a_tpl, create {WSF_AGENT_URI_TEMPLATE_RESPONSE_HANDLER}.make (a_action)), rqst_methods)
|
||||
router.map_with_request_methods (create {WSF_URI_TEMPLATE_MAPPING}.make (a_tpl, create {WSF_URI_TEMPLATE_RESPONSE_AGENT_HANDLER}.make (a_action)), rqst_methods)
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
@@ -114,7 +114,7 @@ feature -- Execution
|
||||
res.send (mesg)
|
||||
end
|
||||
|
||||
response_user (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST): WSF_RESPONSE_MESSAGE
|
||||
response_user (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE
|
||||
-- Computed response message.
|
||||
local
|
||||
html: WSF_HTML_PAGE_RESPONSE
|
||||
@@ -122,7 +122,7 @@ feature -- Execution
|
||||
s: STRING_8
|
||||
l_username: STRING_32
|
||||
do
|
||||
if attached {WSF_STRING} ctx.path_parameter ("user") as u then
|
||||
if attached {WSF_STRING} req.path_parameter ("user") as u then
|
||||
l_username := (create {HTML_ENCODER}).general_decoded_string (u.value)
|
||||
if
|
||||
attached {WSF_STRING} req.query_parameter ("op") as l_op
|
||||
|
||||
@@ -13,16 +13,16 @@ inherit
|
||||
|
||||
feature -- Access
|
||||
|
||||
response (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST): WSF_RESPONSE_MESSAGE
|
||||
response (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE
|
||||
local
|
||||
l_username: READABLE_STRING_32
|
||||
do
|
||||
if attached {WSF_STRING} ctx.path_parameter ("user") as u then
|
||||
if attached {WSF_STRING} req.path_parameter ("user") as u then
|
||||
l_username := html_decoded_string (u.value)
|
||||
if req.is_request_method ("GET") then
|
||||
Result := user_message_get (l_username, ctx, req)
|
||||
Result := user_message_get (l_username, req)
|
||||
elseif req.is_request_method ("POST") then
|
||||
Result := user_message_response_post (l_username, ctx, req)
|
||||
Result := user_message_response_post (l_username, req)
|
||||
else
|
||||
Result := unsupported_method_response (req)
|
||||
end
|
||||
@@ -46,7 +46,7 @@ feature -- Access
|
||||
end
|
||||
|
||||
|
||||
user_message_get (u: READABLE_STRING_32; ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST): WSF_HTML_PAGE_RESPONSE
|
||||
user_message_get (u: READABLE_STRING_32; req: WSF_REQUEST): WSF_HTML_PAGE_RESPONSE
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
@@ -59,7 +59,7 @@ feature -- Access
|
||||
Result.set_body (s)
|
||||
end
|
||||
|
||||
user_message_response_post (u: READABLE_STRING_32; ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST): WSF_HTML_PAGE_RESPONSE
|
||||
user_message_response_post (u: READABLE_STRING_32; req: WSF_REQUEST): WSF_HTML_PAGE_RESPONSE
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
|
||||
@@ -91,7 +91,7 @@ feature -- Execution
|
||||
res.redirect_now_with_content (req.script_url ("/"), uri + ": not found.%NRedirection to " + req.script_url ("/"), "text/html")
|
||||
end
|
||||
|
||||
execute_upload (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
execute_upload (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Upload page is requested, either GET or POST
|
||||
-- On GET display the web form to upload file, by passing ?nb=5 you can upload 5 images
|
||||
-- On POST display the uploaded files
|
||||
@@ -110,14 +110,14 @@ feature -- Execution
|
||||
page.set_body (l_body)
|
||||
l_body.append ("<h1>EWF: Upload image file</h1>%N")
|
||||
l_body.append ("<form action=%""+ req.script_url ("/upload") +"%" method=%"POST%" enctype=%"multipart/form-data%">%N")
|
||||
if attached ctx.string_query_parameter ("nb") as p_nb and then p_nb.is_integer then
|
||||
n := p_nb.to_integer
|
||||
if attached {WSF_STRING} req.query_parameter ("nb") as p_nb and then p_nb.is_integer then
|
||||
n := p_nb.integer_value
|
||||
else
|
||||
n := 1
|
||||
end
|
||||
if attached ctx.string_query_parameter ("demo") as p_demo then
|
||||
if attached {WSF_STRING} req.query_parameter ("demo") as p_demo then
|
||||
create fn.make_from_string (document_root)
|
||||
fn.set_file_name (p_demo.string)
|
||||
fn.set_file_name (p_demo.value)
|
||||
l_body.append ("File: <input type=%"file%" name=%"uploaded_file[]%" size=%"60%" value=%""+ html_encode (fn.string) +"%"></br>%N")
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user