First try to get a limited WGI_ and use WSF_ as default framework
This commit is contained in:
@@ -9,7 +9,7 @@ class
|
||||
|
||||
feature -- Access
|
||||
|
||||
accepted_content_types (req: WGI_REQUEST): detachable ARRAYED_LIST [READABLE_STRING_8]
|
||||
accepted_content_types (req: WSF_REQUEST): detachable ARRAYED_LIST [READABLE_STRING_8]
|
||||
local
|
||||
s: STRING_8
|
||||
q: READABLE_STRING_8
|
||||
|
||||
@@ -9,7 +9,7 @@ class
|
||||
|
||||
feature -- Execute template
|
||||
|
||||
execute_methods (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute_methods (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request and dispatch according to the request method
|
||||
local
|
||||
m: READABLE_STRING_8
|
||||
@@ -41,7 +41,7 @@ feature -- Execute template
|
||||
|
||||
feature -- Method Post
|
||||
|
||||
execute_post (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
if req.content_length_value > 0 then
|
||||
do_post (ctx, req, res)
|
||||
@@ -50,14 +50,14 @@ feature -- Method Post
|
||||
end
|
||||
end
|
||||
|
||||
do_post (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_not_implemented ("Method POST not implemented", ctx, req, res)
|
||||
end
|
||||
|
||||
feature-- Method Put
|
||||
|
||||
execute_put (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
if req.content_length_value > 0 then
|
||||
do_put (ctx, req, res)
|
||||
@@ -66,91 +66,91 @@ feature-- Method Put
|
||||
end
|
||||
end
|
||||
|
||||
do_put (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_not_implemented ("Method PUT not implemented", ctx, req, res)
|
||||
end
|
||||
|
||||
feature -- Method Get
|
||||
|
||||
execute_get (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute_get (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_get (ctx, req, res)
|
||||
end
|
||||
|
||||
do_get (ctx: C;req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do_get (ctx: C;req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_not_implemented ("Method HEAD not implemented", ctx, req, res)
|
||||
end
|
||||
|
||||
feature -- Method DELETE
|
||||
|
||||
execute_delete (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute_delete (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_delete (ctx, req, res)
|
||||
end
|
||||
|
||||
do_delete (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do_delete (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_not_implemented ("Method DELETE not implemented", ctx, req, res)
|
||||
end
|
||||
|
||||
feature -- Method CONNECT
|
||||
|
||||
execute_connect (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute_connect (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_connect (ctx, req, res)
|
||||
end
|
||||
|
||||
do_connect (ctx: C;req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do_connect (ctx: C;req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_not_implemented ("Method CONNECT not implemented", ctx, req, res)
|
||||
end
|
||||
|
||||
feature -- Method HEAD
|
||||
|
||||
execute_head (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute_head (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_head (ctx, req, res)
|
||||
end
|
||||
|
||||
do_head (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do_head (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_not_implemented ("Method HEAD not implemented", ctx, req, res)
|
||||
end
|
||||
|
||||
feature -- Method OPTIONS
|
||||
|
||||
execute_options (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute_options (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_options (ctx, req, res)
|
||||
end
|
||||
|
||||
do_options (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do_options (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_not_implemented ("Method OPTIONS not implemented", ctx, req, res)
|
||||
end
|
||||
|
||||
feature -- Method TRACE
|
||||
|
||||
execute_trace (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute_trace (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_trace (ctx, req, res)
|
||||
end
|
||||
|
||||
do_trace (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do_trace (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_not_implemented ("Method TRACE not implemented", ctx, req, res)
|
||||
end
|
||||
|
||||
feature -- Method Extension Method
|
||||
|
||||
execute_extension_method (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute_extension_method (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_extension_method (ctx, req, res)
|
||||
end
|
||||
|
||||
do_extension_method (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do_extension_method (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_not_implemented ("Method extension-method not implemented", ctx, req, res)
|
||||
end
|
||||
@@ -164,9 +164,9 @@ feature -- Handle responses
|
||||
Result := Void
|
||||
end
|
||||
|
||||
handle_bad_request_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER )
|
||||
handle_bad_request_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
|
||||
local
|
||||
h : EWF_HEADER
|
||||
h : WSF_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_status ({HTTP_STATUS_CODE}.bad_request)
|
||||
@@ -182,9 +182,9 @@ feature -- Handle responses
|
||||
res.write_string (a_description)
|
||||
end
|
||||
|
||||
handle_internal_server_error (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER )
|
||||
handle_internal_server_error (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
|
||||
local
|
||||
h : EWF_HEADER
|
||||
h : WSF_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_status ({HTTP_STATUS_CODE}.internal_server_error)
|
||||
@@ -202,9 +202,9 @@ feature -- Handle responses
|
||||
res.write_string (a_description)
|
||||
end
|
||||
|
||||
handle_not_implemented (a_description: STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER )
|
||||
handle_not_implemented (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
|
||||
local
|
||||
h : EWF_HEADER
|
||||
h : WSF_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_status ({HTTP_STATUS_CODE}.not_implemented)
|
||||
@@ -220,9 +220,9 @@ feature -- Handle responses
|
||||
res.write_string (a_description)
|
||||
end
|
||||
|
||||
handle_resource_not_found_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
handle_resource_not_found_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
h : EWF_HEADER
|
||||
h : WSF_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_status ({HTTP_STATUS_CODE}.not_found)
|
||||
|
||||
@@ -12,7 +12,7 @@ inherit
|
||||
|
||||
feature -- Helper
|
||||
|
||||
execute_content_type_not_allowed (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; a_content_types: detachable ARRAY [STRING]; a_uri_formats: detachable ARRAY [STRING])
|
||||
execute_content_type_not_allowed (req: WSF_REQUEST; res: WSF_RESPONSE; a_content_types: detachable ARRAY [STRING]; a_uri_formats: detachable ARRAY [STRING])
|
||||
local
|
||||
accept_s, uri_s: detachable STRING
|
||||
i, n: INTEGER
|
||||
@@ -62,7 +62,7 @@ feature -- Helper
|
||||
end
|
||||
end
|
||||
|
||||
execute_request_method_not_allowed (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; a_methods: ITERABLE [STRING])
|
||||
execute_request_method_not_allowed (req: WSF_REQUEST; res: WSF_RESPONSE; a_methods: ITERABLE [STRING])
|
||||
local
|
||||
s: STRING
|
||||
do
|
||||
|
||||
@@ -22,11 +22,11 @@ feature -- Initialization
|
||||
|
||||
feature -- Access
|
||||
|
||||
action: PROCEDURE [ANY, TUPLE [ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]]
|
||||
action: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
action.call ([ctx, req, res])
|
||||
end
|
||||
|
||||
@@ -45,10 +45,10 @@ feature -- Element change
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
local
|
||||
h: EWF_HEADER
|
||||
h: WSF_HEADER
|
||||
s: STRING
|
||||
uri: STRING
|
||||
do
|
||||
@@ -68,7 +68,7 @@ feature -- Execution
|
||||
end
|
||||
end
|
||||
|
||||
process_uri (uri: READABLE_STRING_8; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
process_uri (uri: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
f: RAW_FILE
|
||||
fn: READABLE_STRING_8
|
||||
@@ -90,9 +90,9 @@ feature -- Execution
|
||||
end
|
||||
end
|
||||
|
||||
respond_index (a_uri: READABLE_STRING_8; dn: READABLE_STRING_8; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
respond_index (a_uri: READABLE_STRING_8; dn: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
h: EWF_HEADER
|
||||
h: WSF_HEADER
|
||||
uri, s: STRING_8
|
||||
d: DIRECTORY
|
||||
l_files: LIST [STRING_8]
|
||||
@@ -145,10 +145,10 @@ feature -- Execution
|
||||
d.close
|
||||
end
|
||||
|
||||
respond_file (f: FILE; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
respond_file (f: FILE; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
fn: READABLE_STRING_8
|
||||
h: EWF_HEADER
|
||||
h: WSF_HEADER
|
||||
ext: READABLE_STRING_8
|
||||
ct: detachable READABLE_STRING_8
|
||||
do
|
||||
@@ -175,9 +175,9 @@ feature -- Execution
|
||||
res.flush
|
||||
end
|
||||
|
||||
respond_not_found (uri: READABLE_STRING_8; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
respond_not_found (uri: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
h: EWF_HEADER
|
||||
h: WSF_HEADER
|
||||
s: STRING_8
|
||||
do
|
||||
create h.make
|
||||
@@ -191,9 +191,9 @@ feature -- Execution
|
||||
res.flush
|
||||
end
|
||||
|
||||
respond_access_denied (uri: READABLE_STRING_8; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
respond_access_denied (uri: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
h: EWF_HEADER
|
||||
h: WSF_HEADER
|
||||
s: STRING_8
|
||||
do
|
||||
create h.make
|
||||
|
||||
@@ -17,7 +17,7 @@ inherit
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_valid_context (req: WGI_REQUEST): BOOLEAN
|
||||
is_valid_context (req: WSF_REQUEST): BOOLEAN
|
||||
-- Is `req' valid context for current handler?
|
||||
do
|
||||
Result := True
|
||||
@@ -25,7 +25,7 @@ feature -- Status report
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
require
|
||||
is_valid_context: is_valid_context (req)
|
||||
@@ -34,7 +34,7 @@ feature -- Execution
|
||||
|
||||
feature -- Execution: report
|
||||
|
||||
url (req: WGI_REQUEST; a_base: detachable READABLE_STRING_8; args: detachable STRING; abs: BOOLEAN): STRING
|
||||
url (req: WSF_REQUEST; a_base: detachable READABLE_STRING_8; args: detachable STRING; abs: BOOLEAN): STRING
|
||||
-- Associated url based on `a_base' and `args'
|
||||
-- if `abs' then return absolute url
|
||||
local
|
||||
|
||||
@@ -16,7 +16,7 @@ inherit
|
||||
|
||||
feature -- Access
|
||||
|
||||
request: WGI_REQUEST
|
||||
request: WSF_REQUEST
|
||||
-- Associated request
|
||||
|
||||
path: READABLE_STRING_8
|
||||
@@ -71,12 +71,11 @@ feature -- Query
|
||||
|
||||
request_content_type (content_type_supported: detachable ARRAY [READABLE_STRING_8]): detachable READABLE_STRING_8
|
||||
local
|
||||
s: detachable READABLE_STRING_32
|
||||
s: detachable READABLE_STRING_8
|
||||
i,n: INTEGER
|
||||
do
|
||||
s := request.content_type
|
||||
if s /= Void then
|
||||
Result := s
|
||||
if attached request.content_type as ct then
|
||||
Result := ct
|
||||
else
|
||||
if attached accepted_content_types (request) as l_accept_lst then
|
||||
from
|
||||
@@ -108,18 +107,18 @@ feature -- Query
|
||||
|
||||
feature -- Query
|
||||
|
||||
path_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
path_parameter (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
|
||||
-- Parameter value for path variable `a_name'
|
||||
deferred
|
||||
end
|
||||
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
|
||||
-- Parameter value for query variable `a_name'
|
||||
--| i.e after the ? character
|
||||
deferred
|
||||
end
|
||||
|
||||
parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
parameter (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
|
||||
-- Any parameter value for variable `a_name'
|
||||
-- URI template parameter and query parameters
|
||||
do
|
||||
@@ -131,9 +130,9 @@ feature -- Query
|
||||
|
||||
feature -- String query
|
||||
|
||||
string_from (a_value: detachable WGI_VALUE): detachable READABLE_STRING_32
|
||||
string_from (a_value: detachable WSF_VALUE): detachable READABLE_STRING_32
|
||||
do
|
||||
if attached {WGI_STRING_VALUE} a_value as val then
|
||||
if attached {WSF_STRING_VALUE} a_value as val then
|
||||
Result := val.string
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,12 +34,12 @@ feature -- Mapping
|
||||
deferred
|
||||
end
|
||||
|
||||
map_agent (a_resource: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]])
|
||||
map_agent (a_resource: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]])
|
||||
do
|
||||
map_agent_with_request_methods (a_resource, a_action, Void)
|
||||
end
|
||||
|
||||
map_agent_with_request_methods (a_resource: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]];
|
||||
map_agent_with_request_methods (a_resource: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]];
|
||||
rqst_methods: detachable ARRAY [READABLE_STRING_8])
|
||||
local
|
||||
rah: REQUEST_AGENT_HANDLER [C]
|
||||
@@ -65,14 +65,14 @@ feature -- Base url
|
||||
|
||||
feature -- Execution
|
||||
|
||||
dispatch (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER): BOOLEAN
|
||||
dispatch (req: WSF_REQUEST; res: WSF_RESPONSE): BOOLEAN
|
||||
-- Dispatch `req, res' to the associated handler
|
||||
-- And return True is handled, otherwise False
|
||||
do
|
||||
Result := dispatch_and_return_handler (req, res) /= Void
|
||||
end
|
||||
|
||||
dispatch_and_return_handler (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER): detachable H
|
||||
dispatch_and_return_handler (req: WSF_REQUEST; res: WSF_RESPONSE): detachable H
|
||||
-- Dispatch `req, res' to the associated handler
|
||||
-- And return this handler
|
||||
-- If Result is Void, this means no handler was found.
|
||||
@@ -108,13 +108,13 @@ feature -- Traversing
|
||||
|
||||
feature {NONE} -- Access: Implementation
|
||||
|
||||
source_uri (req: WGI_REQUEST): READABLE_STRING_32
|
||||
source_uri (req: WSF_REQUEST): READABLE_STRING_32
|
||||
-- URI to use to find handler.
|
||||
do
|
||||
Result := req.path_info
|
||||
end
|
||||
|
||||
handler (req: WGI_REQUEST): detachable TUPLE [handler: H; context: like default_handler_context]
|
||||
handler (req: WSF_REQUEST): detachable TUPLE [handler: H; context: like default_handler_context]
|
||||
-- Handler whose map matched with `req'
|
||||
require
|
||||
req_valid: source_uri (req) /= Void
|
||||
@@ -179,7 +179,7 @@ feature {NONE} -- Implementation
|
||||
deferred
|
||||
end
|
||||
|
||||
default_handler_context (req: WGI_REQUEST): C
|
||||
default_handler_context (req: WSF_REQUEST): C
|
||||
-- Default handler context associated with `default_handler'
|
||||
require
|
||||
has_default_handler: default_handler /= Void
|
||||
|
||||
@@ -13,7 +13,7 @@ inherit
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
local
|
||||
hdl: detachable H
|
||||
@@ -49,12 +49,12 @@ feature -- Mapping
|
||||
router.map_with_request_methods (a_resource, h, rqst_methods)
|
||||
end
|
||||
|
||||
map_agent (a_resource: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]])
|
||||
map_agent (a_resource: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]])
|
||||
do
|
||||
router.map_agent (a_resource, a_action)
|
||||
end
|
||||
|
||||
map_agent_with_request_methods (a_resource: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]];
|
||||
map_agent_with_request_methods (a_resource: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]];
|
||||
rqst_methods: detachable ARRAY [READABLE_STRING_8])
|
||||
do
|
||||
router.map_agent_with_request_methods (a_resource, a_action, rqst_methods)
|
||||
|
||||
@@ -35,7 +35,7 @@ feature -- Setup
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
l_handled: BOOLEAN
|
||||
rescued: BOOLEAN
|
||||
@@ -50,11 +50,11 @@ feature -- Execution
|
||||
end
|
||||
end
|
||||
|
||||
execute_default (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
deferred
|
||||
end
|
||||
|
||||
execute_rescue (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
execute_rescue (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
if not res.header_committed then
|
||||
res.write_header ({HTTP_STATUS_CODE}.internal_server_error, Void)
|
||||
|
||||
@@ -17,7 +17,7 @@ create
|
||||
|
||||
feature -- Mapping
|
||||
|
||||
map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: REQUEST_URI_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]];
|
||||
map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: REQUEST_URI_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE]];
|
||||
rqst_methods: detachable ARRAY [READABLE_STRING_8])
|
||||
local
|
||||
h: REQUEST_AGENT_HANDLER [REQUEST_URI_HANDLER_CONTEXT]
|
||||
|
||||
@@ -15,7 +15,7 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WGI_REQUEST; p: like path)
|
||||
make (req: WSF_REQUEST; p: like path)
|
||||
do
|
||||
request := req
|
||||
path := p
|
||||
@@ -23,11 +23,11 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Query
|
||||
|
||||
path_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
path_parameter (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
|
||||
do
|
||||
end
|
||||
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
|
||||
do
|
||||
Result := request.query_parameter (a_name)
|
||||
end
|
||||
|
||||
@@ -38,7 +38,7 @@ feature -- Registration
|
||||
|
||||
feature {NONE} -- Access: Implementation
|
||||
|
||||
handler (req: WGI_REQUEST): detachable TUPLE [handler: H; context: like default_handler_context]
|
||||
handler (req: WSF_REQUEST): detachable TUPLE [handler: H; context: like default_handler_context]
|
||||
local
|
||||
h: detachable H
|
||||
ctx: detachable like default_handler_context
|
||||
@@ -62,7 +62,7 @@ feature {NONE} -- Access: Implementation
|
||||
end
|
||||
end
|
||||
|
||||
smart_handler (req: WGI_REQUEST): detachable TUPLE [path: READABLE_STRING_8; handler: H]
|
||||
smart_handler (req: WSF_REQUEST): detachable TUPLE [path: READABLE_STRING_8; handler: H]
|
||||
require
|
||||
req_valid: req /= Void and then source_uri (req) /= Void
|
||||
do
|
||||
@@ -124,7 +124,7 @@ feature {NONE} -- Access: Implementation
|
||||
|
||||
feature {NONE} -- Context factory
|
||||
|
||||
handler_context (p: detachable STRING; req: WGI_REQUEST): C
|
||||
handler_context (p: detachable STRING; req: WSF_REQUEST): C
|
||||
local
|
||||
ctx: C
|
||||
do
|
||||
@@ -184,7 +184,7 @@ feature {NONE} -- Default: implementation
|
||||
default_handler := h
|
||||
end
|
||||
|
||||
default_handler_context (req: WGI_REQUEST): C
|
||||
default_handler_context (req: WSF_REQUEST): C
|
||||
do
|
||||
Result := handler_context (Void, req)
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ create
|
||||
|
||||
feature -- Mapping
|
||||
|
||||
map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]];
|
||||
map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE]];
|
||||
rqst_methods: detachable ARRAY [READABLE_STRING_8])
|
||||
local
|
||||
h: REQUEST_AGENT_HANDLER [REQUEST_URI_TEMPLATE_HANDLER_CONTEXT]
|
||||
|
||||
@@ -15,7 +15,7 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WGI_REQUEST; tpl: URI_TEMPLATE; tpl_res: URI_TEMPLATE_MATCH_RESULT; p: like path)
|
||||
make (req: WSF_REQUEST; tpl: URI_TEMPLATE; tpl_res: URI_TEMPLATE_MATCH_RESULT; p: like path)
|
||||
do
|
||||
request := req
|
||||
uri_template := tpl
|
||||
@@ -31,17 +31,17 @@ feature -- Access
|
||||
|
||||
feature -- Query
|
||||
|
||||
path_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
path_parameter (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
|
||||
do
|
||||
if attached uri_template_match.url_decoded_path_variable (a_name) as s then
|
||||
create {WGI_STRING_VALUE} Result.make (a_name, s)
|
||||
create {WSF_STRING_VALUE} Result.make (a_name, s)
|
||||
end
|
||||
end
|
||||
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
|
||||
do
|
||||
if attached uri_template_match.url_decoded_query_variable (a_name) as s then
|
||||
create {WGI_STRING_VALUE} Result.make (a_name, s)
|
||||
create {WSF_STRING_VALUE} Result.make (a_name, s)
|
||||
else
|
||||
Result := request.query_parameter (a_name)
|
||||
end
|
||||
|
||||
@@ -54,7 +54,7 @@ feature -- Registration
|
||||
|
||||
feature {NONE} -- Access: Implementation
|
||||
|
||||
handler (req: WGI_REQUEST): detachable TUPLE [handler: attached like default_handler; context: like default_handler_context]
|
||||
handler (req: WSF_REQUEST): detachable TUPLE [handler: attached like default_handler; context: like default_handler_context]
|
||||
local
|
||||
l_handlers: like handlers
|
||||
t: STRING
|
||||
@@ -94,7 +94,7 @@ feature {NONE} -- Access: Implementation
|
||||
|
||||
feature {NONE} -- Context factory
|
||||
|
||||
handler_context (p: detachable STRING; req: WGI_REQUEST; tpl: URI_TEMPLATE; tpl_res: URI_TEMPLATE_MATCH_RESULT): C
|
||||
handler_context (p: detachable STRING; req: WSF_REQUEST; tpl: URI_TEMPLATE; tpl_res: URI_TEMPLATE_MATCH_RESULT): C
|
||||
do
|
||||
if p /= Void then
|
||||
create Result.make (req, tpl, tpl_res, p)
|
||||
@@ -151,7 +151,7 @@ feature {NONE} -- Default: implementation
|
||||
default_handler := h
|
||||
end
|
||||
|
||||
default_handler_context (req: WGI_REQUEST): C
|
||||
default_handler_context (req: WSF_REQUEST): C
|
||||
do
|
||||
Result := handler_context (Void, req, create {URI_TEMPLATE}.make ("/"), create {URI_TEMPLATE_MATCH_RESULT}.make_empty)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user