Added WSF_REQUEST_UTILITY_PROXY, that provides the WSF_REQUEST_UTILITY features to a class that implement request: WSF_REQUEST

This commit is contained in:
Jocelyn Fiat
2012-10-22 17:09:57 +02:00
parent 7dce121f8c
commit 50d5254060
2 changed files with 150 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ deferred class
inherit inherit
WSF_HANDLER_CONTEXT WSF_HANDLER_CONTEXT
WSF_REQUEST_UTILITY WSF_REQUEST_UTILITY_PROXY
feature -- Accept: Content-Type feature -- Accept: Content-Type
@@ -25,7 +25,7 @@ feature -- Accept: Content-Type
get_accepted_content_type (a_supported_content_types: detachable ARRAY [STRING_8]) get_accepted_content_type (a_supported_content_types: detachable ARRAY [STRING_8])
do do
if internal_accepted_content_type = Void then if internal_accepted_content_type = Void then
internal_accepted_content_type := request_accepted_content_type (request, a_supported_content_types) internal_accepted_content_type := request_accepted_content_type (a_supported_content_types)
end end
end end
@@ -78,7 +78,7 @@ feature -- Format
if a_format_variable_name /= Void and then attached {WSF_STRING} request.item (a_format_variable_name) as ctx_format then if a_format_variable_name /= Void and then attached {WSF_STRING} request.item (a_format_variable_name) as ctx_format then
Result := ctx_format.value Result := ctx_format.value
else else
Result := request_format_from_content_type (request_accepted_content_type (request, a_supported_content_types)) Result := request_format_from_content_type (request_accepted_content_type (a_supported_content_types))
end end
end end

View File

@@ -0,0 +1,147 @@
note
description: "Summary description for {WSF_REQUES_UTILITY_PROXY}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_REQUEST_UTILITY_PROXY
feature {NONE} -- Implementation
utility: WSF_REQUEST_UTILITY
once
create Result
end
feature -- Request
request: WSF_REQUEST
deferred
end
feature -- Url Query
script_absolute_url (a_path: STRING): STRING
-- Absolute Url for the script if any, extended by `a_path'
do
Result := utility.script_absolute_url (request, a_path)
end
script_url (a_path: STRING): STRING
-- Url relative to script name if any, extended by `a_path'
do
Result := utility.script_url (request, a_path)
end
url (args: detachable STRING; abs: BOOLEAN): STRING
-- Associated url based on `path' and `args'
-- if `abs' then return absolute url
do
Result := utility.url (request, request.script_name, args, abs)
end
feature -- Parameter
item (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
-- Variable value for parameter or variable `a_name'
-- See `{WSF_REQUEST}.item(s)'
do
Result := utility.item (request, a_name)
end
string_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
-- String value for any variable of parameter `a_name' if relevant.
do
Result := utility.string_item (request, a_name)
end
string_array_item (a_name: READABLE_STRING_GENERAL): detachable ARRAY [READABLE_STRING_32]
-- Array of string values for query parameter `a_name' if relevant.
do
Result := utility.string_array_item (request, a_name)
end
feature -- Query parameter
query_parameter (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
-- Parameter value for query variable `a_name'
--| i.e after the ? character
do
Result := utility.query_parameter (request, a_name)
end
string_query_parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
-- String value for query parameter `a_name' if relevant.
do
Result := utility.string_query_parameter (request, a_name)
end
string_array_query_parameter (a_name: READABLE_STRING_GENERAL): detachable ARRAY [READABLE_STRING_32]
-- Array of string values for query parameter `a_name' if relevant.
do
Result := utility.string_array_query_parameter (request, a_name)
end
is_integer_query_parameter (a_name: READABLE_STRING_GENERAL): BOOLEAN
-- Is query parameter related to `a_name' an integer value?
do
Result := utility.is_integer_query_parameter (request, a_name)
end
integer_query_parameter (a_name: READABLE_STRING_GENERAL): INTEGER
-- Integer value for query parameter `a_name' if relevant.
do
Result := utility.integer_query_parameter (request, a_name)
end
feature -- Path parameter
path_parameter (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
do
Result := utility.path_parameter (request, a_name)
end
string_path_parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
-- String value for path parameter `a_name' if relevant.
do
Result := utility.string_path_parameter (request, a_name)
end
string_array_path_parameter (a_name: READABLE_STRING_GENERAL): detachable ARRAY [READABLE_STRING_32]
-- Array of string values for path parameter `a_name' if relevant.
do
Result := utility.string_array_path_parameter (request, a_name)
end
is_integer_path_parameter (a_name: READABLE_STRING_GENERAL): BOOLEAN
-- Is path parameter related to `a_name' an integer value?
do
Result := utility.is_integer_path_parameter (request, a_name)
end
integer_path_parameter (a_name: READABLE_STRING_GENERAL): INTEGER
-- Integer value for path parameter `a_name' if relevant.
do
Result := utility.integer_path_parameter (request, a_name)
end
feature -- Content type
request_accepted_content_type (a_supported_content_types: detachable ARRAY [READABLE_STRING_8]): detachable READABLE_STRING_8
-- Accepted content-type for the request, among the supported content types `a_supported_content_types'
do
Result := utility.request_accepted_content_type (request, a_supported_content_types)
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