- Adopted deferred WGI_VALUE design for Result type of *_parameter and similar functions
- Adopted the ITERATION_CURSOR [WGI_VALUE] design for *_parameters and similar functions - renamed parameter as item - provided helper function to handle "string" value parameters Experimental for now.
This commit is contained in:
@@ -38,10 +38,15 @@ feature -- Execution
|
||||
execute (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
local
|
||||
l_handled: BOOLEAN
|
||||
rescued: BOOLEAN
|
||||
do
|
||||
l_handled := router.dispatch (req, res)
|
||||
if not l_handled then
|
||||
execute_default (req, res)
|
||||
if not rescued then
|
||||
l_handled := router.dispatch (req, res)
|
||||
if not l_handled then
|
||||
execute_default (req, res)
|
||||
end
|
||||
else
|
||||
execute_rescue (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,6 +54,14 @@ feature -- Execution
|
||||
deferred
|
||||
end
|
||||
|
||||
execute_rescue (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do
|
||||
if not res.header_committed then
|
||||
res.write_header ({HTTP_STATUS_CODE}.internal_server_error, Void)
|
||||
end
|
||||
res.flush
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
@@ -35,7 +35,7 @@ feature -- Query
|
||||
request_format (a_format_variable_name: detachable READABLE_STRING_GENERAL; content_type_supported: detachable ARRAY [READABLE_STRING_8]): detachable READABLE_STRING_8
|
||||
-- Format id for the request based on {HTTP_FORMAT_CONSTANTS}
|
||||
do
|
||||
if a_format_variable_name /= Void and then attached parameter (a_format_variable_name) as ctx_format then
|
||||
if a_format_variable_name /= Void and then attached string_parameter (a_format_variable_name) as ctx_format then
|
||||
Result := ctx_format.as_string_8
|
||||
else
|
||||
Result := content_type_to_request_format (request_content_type (content_type_supported))
|
||||
@@ -107,27 +107,51 @@ feature -- Query
|
||||
|
||||
feature -- Query
|
||||
|
||||
path_parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
path_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
-- Parameter value for path variable `a_name'
|
||||
deferred
|
||||
end
|
||||
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
-- Parameter value for query variable `a_name'
|
||||
--| i.e after the ? character
|
||||
deferred
|
||||
end
|
||||
|
||||
parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
-- Any parameter value for variable `a_name'
|
||||
-- URI template parameter and query parameters
|
||||
do
|
||||
Result := query_parameter (a_name)
|
||||
Result := query_parameter (a_name)
|
||||
if Result = Void then
|
||||
Result := path_parameter (a_name)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- String query
|
||||
|
||||
string_from (a_value: detachable WGI_VALUE): detachable READABLE_STRING_32
|
||||
do
|
||||
if attached {WGI_STRING_VALUE} a_value as val then
|
||||
Result := val.value
|
||||
end
|
||||
end
|
||||
|
||||
string_path_parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
do
|
||||
Result := string_from (path_parameter (a_name))
|
||||
end
|
||||
|
||||
string_query_parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
do
|
||||
Result := string_from (query_parameter (a_name))
|
||||
end
|
||||
|
||||
string_parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
do
|
||||
Result := string_from (parameter (a_name))
|
||||
end
|
||||
|
||||
;note
|
||||
copyright: "2011-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
@@ -23,13 +23,13 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Query
|
||||
|
||||
path_parameter (a_name: READABLE_STRING_GENERAL): detachable STRING_32
|
||||
path_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
do
|
||||
end
|
||||
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
do
|
||||
Result := request.parameter (a_name)
|
||||
Result := request.query_parameter (a_name)
|
||||
end
|
||||
|
||||
note
|
||||
|
||||
@@ -31,16 +31,19 @@ feature -- Access
|
||||
|
||||
feature -- Query
|
||||
|
||||
path_parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
path_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
do
|
||||
Result := uri_template_match.url_decoded_path_variable (a_name)
|
||||
if attached uri_template_match.url_decoded_path_variable (a_name) as s then
|
||||
create {WGI_STRING_VALUE} Result.make (a_name, s)
|
||||
end
|
||||
end
|
||||
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
do
|
||||
Result := uri_template_match.url_decoded_query_variable (a_name)
|
||||
if Result = Void then
|
||||
Result := request.parameter (a_name)
|
||||
if attached uri_template_match.url_decoded_query_variable (a_name) as s then
|
||||
create {WGI_STRING_VALUE} Result.make (a_name, s)
|
||||
else
|
||||
Result := request.query_parameter (a_name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
note
|
||||
description: "Summary description for {DEFAULT_REQUEST_URI_ROUTING_HANDLER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
DEFAULT_REQUEST_URI_ROUTING_HANDLER
|
||||
|
||||
inherit
|
||||
REQUEST_URI_ROUTING_HANDLER [REQUEST_HANDLER [REQUEST_URI_HANDLER_CONTEXT], REQUEST_URI_HANDLER_CONTEXT]
|
||||
redefine
|
||||
router
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Routing
|
||||
|
||||
router: DEFAULT_REQUEST_URI_ROUTER
|
||||
|
||||
;note
|
||||
copyright: "2011-2011, 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