Merge remote-tracking branch 'jocelynEWF/master'
Conflicts: examples/restbucks/restbucks-safe.ecf examples/restbucks/src/resource/order_handler.e library/server/request/router/src/misc/request_resource_handler_helper.e
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension-safe.ecf"/>
|
||||
<library name="ewsgi" location="..\..\ewsgi\ewsgi-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="..\..\wsf\wsf-safe.ecf" readonly="false"/>
|
||||
<library name="http" location="..\..\..\protocol\http\http-safe.ecf"/>
|
||||
<library name="uri_template" location="..\..\..\protocol\uri_template\uri_template-safe.ecf" readonly="false"/>
|
||||
<cluster name="src" location="src\" recursive="true"/>
|
||||
@@ -29,7 +29,7 @@
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension-safe.ecf"/>
|
||||
<library name="ewsgi" location="..\..\ewsgi\ewsgi_spec-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="..\..\wsf\wsf_spec-safe.ecf" readonly="false"/>
|
||||
<library name="http" location="..\..\..\protocol\http\http-safe.ecf"/>
|
||||
<library name="uri_template" location="..\..\..\protocol\uri_template\uri_template-safe.ecf" readonly="false"/>
|
||||
<cluster name="src" location="src\" recursive="true"/>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension.ecf"/>
|
||||
<library name="ewsgi" location="..\..\ewsgi\ewsgi.ecf"/>
|
||||
<library name="wsf" location="..\..\wsf\wsf.ecf"/>
|
||||
<library name="http" location="..\..\..\protocol\http\http.ecf"/>
|
||||
<library name="uri_template" location="..\..\..\protocol\uri_template\uri_template.ecf"/>
|
||||
<cluster name="src" location="src\" recursive="true"/>
|
||||
@@ -29,7 +29,7 @@
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension.ecf"/>
|
||||
<library name="ewsgi" location="..\..\ewsgi\ewsgi.ecf"/>
|
||||
<library name="wsf" location="..\..\wsf\wsf.ecf"/>
|
||||
<library name="http" location="..\..\..\protocol\http\http.ecf"/>
|
||||
<library name="uri_template" location="..\..\..\protocol\uri_template\uri_template.ecf"/>
|
||||
<cluster name="src" location="src\" recursive="true"/>
|
||||
|
||||
@@ -9,19 +9,16 @@ 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
|
||||
l_accept: detachable READABLE_STRING_32
|
||||
s: STRING_8
|
||||
q: READABLE_STRING_8
|
||||
p: INTEGER
|
||||
lst: LIST [READABLE_STRING_8]
|
||||
qs: QUICK_SORTER [READABLE_STRING_8]
|
||||
do
|
||||
l_accept := req.http_accept
|
||||
--TEST l_accept := "text/html,application/xhtml+xml;q=0.6,application/xml;q=0.2,text/plain;q=0.5,*/*;q=0.8"
|
||||
|
||||
if l_accept /= Void then
|
||||
--TEST if attached ("text/html,application/xhtml+xml;q=0.6,application/xml;q=0.2,text/plain;q=0.5,*/*;q=0.8") as l_accept then
|
||||
if attached req.http_accept as l_accept then
|
||||
lst := l_accept.as_string_8.split (',')
|
||||
create Result.make (lst.count)
|
||||
from
|
||||
|
||||
@@ -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)
|
||||
@@ -183,9 +183,9 @@ feature -- Handle responses
|
||||
end
|
||||
|
||||
|
||||
handle_precondition_fail_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER )
|
||||
handle_precondition_fail_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}.precondition_failed)
|
||||
@@ -201,9 +201,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)
|
||||
@@ -221,9 +221,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)
|
||||
@@ -239,9 +239,9 @@ feature -- Handle responses
|
||||
res.write_string (a_description)
|
||||
end
|
||||
|
||||
handle_method_not_allowed_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER )
|
||||
handle_method_not_allowed_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}.method_not_allowed)
|
||||
@@ -256,9 +256,10 @@ feature -- Handle responses
|
||||
res.write_headers_string (h.string)
|
||||
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)
|
||||
@@ -275,9 +276,9 @@ feature -- Handle responses
|
||||
end
|
||||
|
||||
|
||||
handle_resource_not_modified_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
handle_resource_not_modified_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
h : EWF_HEADER
|
||||
h : WSF_HEADER
|
||||
do
|
||||
res.flush
|
||||
create h.make
|
||||
@@ -295,9 +296,9 @@ feature -- Handle responses
|
||||
end
|
||||
|
||||
|
||||
handle_resource_conflict_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
handle_resource_conflict_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}.conflict)
|
||||
|
||||
@@ -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
|
||||
|
||||
335
library/server/request/router/src/request_file_system_handler.e
Normal file
335
library/server/request/router/src/request_file_system_handler.e
Normal file
@@ -0,0 +1,335 @@
|
||||
note
|
||||
description: "[
|
||||
Request handler used to respond file system request.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
REQUEST_FILE_SYSTEM_HANDLER [C -> REQUEST_HANDLER_CONTEXT]
|
||||
|
||||
inherit
|
||||
REQUEST_HANDLER [C]
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_root: READABLE_STRING_8)
|
||||
require
|
||||
a_root_exists: node_exists (a_root)
|
||||
do
|
||||
document_root := a_root
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
document_root: READABLE_STRING_8
|
||||
-- Document root for the file system
|
||||
|
||||
directory_index: detachable ARRAY [READABLE_STRING_8]
|
||||
-- File serve if a directory index is requested
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_directory_index (idx: like directory_index)
|
||||
-- Set `directory_index' as `idx'
|
||||
do
|
||||
if idx = Void or else idx.is_empty then
|
||||
directory_index := Void
|
||||
else
|
||||
directory_index := idx
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
local
|
||||
h: WSF_HEADER
|
||||
s: STRING
|
||||
uri: STRING
|
||||
do
|
||||
if attached ctx.path_parameter ("path") as l_path then
|
||||
uri := l_path.as_string
|
||||
process_uri (uri, ctx, req, res)
|
||||
else
|
||||
create h.make
|
||||
h.put_content_type_text_html
|
||||
s := "Hello " + ctx.path + "%N"
|
||||
s.append ("root=" + document_root)
|
||||
|
||||
h.put_content_length (s.count)
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.ok)
|
||||
res.write_headers_string (h.string)
|
||||
res.write_string (s)
|
||||
end
|
||||
end
|
||||
|
||||
process_uri (uri: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
f: RAW_FILE
|
||||
fn: READABLE_STRING_8
|
||||
do
|
||||
fn := resource_filename (uri)
|
||||
create f.make (fn)
|
||||
if f.exists then
|
||||
if f.is_readable then
|
||||
if f.is_directory then
|
||||
respond_index (req.request_uri, fn, ctx, req, res)
|
||||
else
|
||||
respond_file (f, ctx, req, res)
|
||||
end
|
||||
else
|
||||
respond_access_denied (uri, ctx, req, res)
|
||||
end
|
||||
else
|
||||
respond_not_found (uri, ctx, req, res)
|
||||
end
|
||||
end
|
||||
|
||||
respond_index (a_uri: READABLE_STRING_8; dn: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
h: WSF_HEADER
|
||||
uri, s: STRING_8
|
||||
d: DIRECTORY
|
||||
l_files: LIST [STRING_8]
|
||||
do
|
||||
create d.make_open_read (dn)
|
||||
if attached directory_index_file (d) as f then
|
||||
respond_file (f, ctx, req, res)
|
||||
else
|
||||
uri := a_uri
|
||||
if not uri.is_empty and then uri [uri.count] /= '/' then
|
||||
uri.append_character ('/')
|
||||
end
|
||||
s := "[
|
||||
<html>
|
||||
<head>
|
||||
<title>Index for folder: $URI</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Index for $URI</h1>
|
||||
<ul>
|
||||
]"
|
||||
s.replace_substring_all ("$URI", uri)
|
||||
|
||||
from
|
||||
l_files := d.linear_representation
|
||||
l_files.start
|
||||
until
|
||||
l_files.after
|
||||
loop
|
||||
s.append ("<li><a href=%"" + uri + l_files.item_for_iteration + "%">" + l_files.item_for_iteration + "</a></li>%N")
|
||||
l_files.forth
|
||||
end
|
||||
s.append ("[
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
]"
|
||||
)
|
||||
|
||||
create h.make
|
||||
h.put_content_type_text_html
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.ok)
|
||||
h.put_content_length (s.count)
|
||||
res.write_headers_string (h.string)
|
||||
if not req.request_method.same_string ({HTTP_REQUEST_METHODS}.method_head) then
|
||||
res.write_string (s)
|
||||
end
|
||||
res.flush
|
||||
end
|
||||
d.close
|
||||
end
|
||||
|
||||
respond_file (f: FILE; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
fn: READABLE_STRING_8
|
||||
h: WSF_HEADER
|
||||
ext: READABLE_STRING_8
|
||||
ct: detachable READABLE_STRING_8
|
||||
do
|
||||
fn := f.name
|
||||
ext := extension (fn)
|
||||
ct := extension_mime_mapping.mime_type (ext)
|
||||
create h.make
|
||||
|
||||
if ct /= Void then
|
||||
h.put_content_type (ct)
|
||||
h.put_content_length (f.count)
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.ok)
|
||||
res.write_headers_string (h.string)
|
||||
else
|
||||
create h.make
|
||||
h.put_content_type ({HTTP_MIME_TYPES}.application_force_download)
|
||||
h.put_content_length (f.count)
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.ok)
|
||||
res.write_headers_string (h.string)
|
||||
end
|
||||
if not req.request_method.same_string ({HTTP_REQUEST_METHODS}.method_head) then
|
||||
res.write_file_content (fn)
|
||||
end
|
||||
res.flush
|
||||
end
|
||||
|
||||
respond_not_found (uri: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
h: WSF_HEADER
|
||||
s: STRING_8
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_text_plain
|
||||
create s.make_empty
|
||||
s.append ("Resource %"" + uri + "%" not found%N")
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.not_found)
|
||||
h.put_content_length (s.count)
|
||||
res.write_headers_string (h.string)
|
||||
res.write_string (s)
|
||||
res.flush
|
||||
end
|
||||
|
||||
respond_access_denied (uri: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
h: WSF_HEADER
|
||||
s: STRING_8
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_text_plain
|
||||
create s.make_empty
|
||||
s.append ("Resource %"" + uri + "%": Access denied%N")
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.forbidden)
|
||||
h.put_content_length (s.count)
|
||||
res.write_headers_string (h.string)
|
||||
res.write_string (s)
|
||||
res.flush
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
directory_index_file (d: DIRECTORY): detachable FILE
|
||||
local
|
||||
f: detachable RAW_FILE
|
||||
fn: FILE_NAME
|
||||
do
|
||||
if attached directory_index as default_index then
|
||||
across
|
||||
default_index as c
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
if d.has_entry (c.item) then
|
||||
create fn.make_from_string (d.name)
|
||||
fn.set_file_name (c.item)
|
||||
if f = Void then
|
||||
create f.make (fn.string)
|
||||
else
|
||||
f.make (fn.string)
|
||||
end
|
||||
if f.exists and then f.is_readable then
|
||||
Result := f
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resource_filename (uri: READABLE_STRING_8): READABLE_STRING_8
|
||||
do
|
||||
Result := real_filename (document_root + real_filename (uri))
|
||||
end
|
||||
|
||||
dirname (uri: READABLE_STRING_8): READABLE_STRING_8
|
||||
local
|
||||
p: INTEGER
|
||||
do
|
||||
p := uri.last_index_of ('/', uri.count)
|
||||
if p > 0 then
|
||||
Result := uri.substring (1, p - 1)
|
||||
else
|
||||
create {STRING_8} Result.make_empty
|
||||
end
|
||||
end
|
||||
|
||||
filename (uri: READABLE_STRING_8): READABLE_STRING_8
|
||||
local
|
||||
p: INTEGER
|
||||
do
|
||||
p := uri.last_index_of ('/', uri.count)
|
||||
if p > 0 then
|
||||
Result := uri.substring (p + 1, uri.count)
|
||||
else
|
||||
Result := uri.twin
|
||||
end
|
||||
end
|
||||
|
||||
extension (uri: READABLE_STRING_8): READABLE_STRING_8
|
||||
local
|
||||
p: INTEGER
|
||||
do
|
||||
p := uri.last_index_of ('.', uri.count)
|
||||
if p > 0 then
|
||||
Result := uri.substring (p + 1, uri.count)
|
||||
else
|
||||
create {STRING_8} Result.make_empty
|
||||
end
|
||||
end
|
||||
|
||||
real_filename (fn: STRING): STRING
|
||||
-- Real filename from url-path `fn'
|
||||
--| Find a better design for this piece of code
|
||||
--| Eventually in a spec/$ISE_PLATFORM/ specific cluster
|
||||
do
|
||||
if fn.is_empty then
|
||||
Result := fn
|
||||
else
|
||||
if {PLATFORM}.is_windows then
|
||||
create Result.make_from_string (fn)
|
||||
Result.replace_substring_all ("/", "\")
|
||||
if Result [Result.count] = '\' then
|
||||
Result.remove_tail (1)
|
||||
end
|
||||
else
|
||||
Result := fn
|
||||
if Result [Result.count] = '/' then
|
||||
Result.remove_tail (1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
node_exists (p: READABLE_STRING_8): BOOLEAN
|
||||
local
|
||||
f: RAW_FILE
|
||||
do
|
||||
create f.make (p)
|
||||
Result := f.exists
|
||||
end
|
||||
|
||||
extension_mime_mapping: HTTP_FILE_EXTENSION_MIME_MAPPING
|
||||
local
|
||||
f: RAW_FILE
|
||||
once
|
||||
create f.make ("mime.types")
|
||||
if f.exists and then f.is_readable then
|
||||
create Result.make_from_file (f.name)
|
||||
else
|
||||
create Result.make_default
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
@@ -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
|
||||
@@ -31,7 +31,7 @@ feature {NONE} -- Constants
|
||||
|
||||
feature -- Query
|
||||
|
||||
request_format (a_format_variable_name: detachable READABLE_STRING_GENERAL; content_type_supported: detachable ARRAY [READABLE_STRING_8]): detachable READABLE_STRING_8
|
||||
request_format (a_format_variable_name: detachable READABLE_STRING_8; 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 string_parameter (a_format_variable_name) as ctx_format then
|
||||
@@ -41,7 +41,7 @@ feature -- Query
|
||||
end
|
||||
end
|
||||
|
||||
request_format_id (a_format_variable_name: detachable READABLE_STRING_GENERAL; content_type_supported: detachable ARRAY [READABLE_STRING_8]): INTEGER
|
||||
request_format_id (a_format_variable_name: detachable READABLE_STRING_8; content_type_supported: detachable ARRAY [READABLE_STRING_8]): INTEGER
|
||||
-- Format id for the request based on {HTTP_FORMAT_CONSTANTS}
|
||||
do
|
||||
if attached request_format (a_format_variable_name, content_type_supported) as l_format then
|
||||
@@ -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_8): 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_8): 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_8): detachable WSF_VALUE
|
||||
-- Any parameter value for variable `a_name'
|
||||
-- URI template parameter and query parameters
|
||||
do
|
||||
@@ -131,24 +130,24 @@ 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
|
||||
|
||||
string_path_parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
string_path_parameter (a_name: READABLE_STRING_8): 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
|
||||
string_query_parameter (a_name: READABLE_STRING_8): detachable READABLE_STRING_32
|
||||
do
|
||||
Result := string_from (query_parameter (a_name))
|
||||
end
|
||||
|
||||
string_parameter (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
string_parameter (a_name: READABLE_STRING_8): detachable READABLE_STRING_32
|
||||
do
|
||||
Result := string_from (parameter (a_name))
|
||||
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_8): detachable WSF_VALUE
|
||||
do
|
||||
end
|
||||
|
||||
query_parameter (a_name: READABLE_STRING_GENERAL): detachable WGI_VALUE
|
||||
query_parameter (a_name: READABLE_STRING_8): 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_8): 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_8): 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,11 +54,11 @@ 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
|
||||
p: STRING
|
||||
t: READABLE_STRING_8
|
||||
p: READABLE_STRING_8
|
||||
l_req_method: READABLE_STRING_GENERAL
|
||||
l_res: URI_TEMPLATE_MATCH_RESULT
|
||||
do
|
||||
@@ -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