First try to get a limited WGI_ and use WSF_ as default framework

This commit is contained in:
Jocelyn Fiat
2011-10-19 00:34:30 +02:00
parent eaa99c9c61
commit aec0136739
51 changed files with 2756 additions and 1082 deletions

View File

@@ -7,12 +7,13 @@
<exclude>/\.git$</exclude>
<exclude>/\.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all"/>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="ewsgi" location="..\..\ewsgi\ewsgi-safe.ecf"/>
<library name="wsf" location="..\..\wsf\wsf-safe.ecf" readonly="false"/>
<library name="http" location="..\..\..\protocol\http\http-safe.ecf"/>
<library name="router" location="..\..\request\router\router-safe.ecf" readonly="false"/>
<library name="uri_template" location="..\..\..\protocol\uri_template\uri_template-safe.ecf"/>
<library name="uri_template" location="..\..\..\protocol\uri_template\uri_template-safe.ecf" readonly="false"/>
<cluster name="contrib" location=".\src\contrib\" recursive="true">
<file_rule>
<exclude>/html$</exclude>

View File

@@ -9,7 +9,7 @@
</file_rule>
<option warning="true" full_class_checking="true"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.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="router" location="..\..\request\router\router.ecf" readonly="false"/>
<library name="uri_template" location="..\..\..\protocol\uri_template\uri_template.ecf"/>

View File

@@ -31,7 +31,7 @@ feature {NONE} -- Initialization
feature -- Access
headers: EWF_HEADER
headers: WSF_HEADER
feature -- Recycle
@@ -155,7 +155,7 @@ feature -- Output
Result := o
end
send (buf: WGI_RESPONSE_BUFFER)
send (buf: WSF_RESPONSE)
do
buf.set_status_code (200)
buf.write_headers_string (header_string)

View File

@@ -30,13 +30,13 @@ feature {NONE} -- Access: Implementation
feature -- Access
authentication_required (req: WGI_REQUEST): BOOLEAN
authentication_required (req: WSF_REQUEST): BOOLEAN
do
end
feature -- Execution
execute_application (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_application (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
local
rep: like new_html_page
s: STRING
@@ -50,7 +50,7 @@ feature -- Execution
create s.make_empty
if
attached {WGI_STRING_VALUE} ctx.path_parameter ("resource") as l_resource_value and then
attached {WSF_STRING_VALUE} ctx.path_parameter ("resource") as l_resource_value and then
attached l_resource_value.string as l_resource
then
from
@@ -114,7 +114,7 @@ feature -- Execution
rep.recycle
end
process_request_handler_doc (rq: REST_REQUEST_HANDLER [C]; a_resource: STRING; buf: STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; a_dft_format: detachable STRING)
process_request_handler_doc (rq: REST_REQUEST_HANDLER [C]; a_resource: STRING; buf: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE; a_dft_format: detachable STRING)
local
l_dft_format_name: detachable STRING
s: STRING

View File

@@ -32,7 +32,7 @@ feature -- Recycle
feature -- Access
headers: EWF_HEADER
headers: WSF_HEADER
api: STRING
-- Associated api query string.
@@ -129,7 +129,7 @@ feature -- Output
Result := o
end
send (res: WGI_RESPONSE_BUFFER)
send (res: WSF_RESPONSE)
do
compute
res.set_status_code (200)

View File

@@ -23,7 +23,7 @@ create
feature -- status
authentication_required (req: WGI_REQUEST): BOOLEAN
authentication_required (req: WSF_REQUEST): BOOLEAN
do
Result := internal_authentication_required
end

View File

@@ -15,7 +15,7 @@ inherit
feature -- Access
authentication_required (req: WGI_REQUEST): BOOLEAN
authentication_required (req: WSF_REQUEST): BOOLEAN
-- Is authentication required
-- might depend on the request environment
-- or the associated resources
@@ -35,7 +35,7 @@ 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
rescued: BOOLEAN
@@ -60,24 +60,24 @@ feature -- Execution
retry
end
execute_application (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_application (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
deferred
end
pre_execute (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
pre_execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
end
post_execute (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
post_execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
end
rescue_execute (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
rescue_execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
post_execute (ctx, req, res)
end
execute_unauthorized (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_unauthorized (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
res.set_status_code ({HTTP_STATUS_CODE}.unauthorized)
res.write_header ({HTTP_STATUS_CODE}.unauthorized, Void)

View File

@@ -18,7 +18,7 @@ create
feature -- Mapping
map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: REST_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: REST_REQUEST_URI_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE]];
rqst_methods: detachable ARRAY [READABLE_STRING_8])
local
h: REST_REQUEST_AGENT_HANDLER [REST_REQUEST_URI_HANDLER_CONTEXT]

View File

@@ -25,7 +25,7 @@ create
feature -- Status report
authentication_required (req: WGI_REQUEST): BOOLEAN
authentication_required (req: WSF_REQUEST): BOOLEAN
do
Result := internal_authentication_required
end
@@ -36,12 +36,12 @@ feature {NONE} -- Implementation
feature -- Execution
execute (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
Precursor {REQUEST_URI_ROUTING_HANDLER_I} (ctx, req, res)
end
execute_application (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_application (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
check should_not_occur: False end
end

View File

@@ -18,7 +18,7 @@ create
feature -- Mapping
map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: PROCEDURE [ANY, TUPLE [ctx: REST_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: REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE]];
rqst_methods: detachable ARRAY [READABLE_STRING_8])
local
h: REST_REQUEST_AGENT_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT]

View File

@@ -25,7 +25,7 @@ create
feature -- Status report
authentication_required (req: WGI_REQUEST): BOOLEAN
authentication_required (req: WSF_REQUEST): BOOLEAN
do
Result := internal_authentication_required
end
@@ -36,14 +36,14 @@ feature {NONE} -- Implementation
feature -- Execution
execute (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
pre_execute (ctx, req, res)
Precursor {REQUEST_URI_TEMPLATE_ROUTING_HANDLER_I} (ctx, req, res)
post_execute (ctx, req, res)
end
execute_application (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_application (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
check should_not_occur: False end
end

View File

@@ -12,7 +12,7 @@
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="rest" location="..\rest-safe.ecf" readonly="false"/>
<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" readonly="false"/>
</target>
<target name="sample_fcgi" extends="common">

View File

@@ -35,14 +35,14 @@ feature {NONE} -- Initialization
feature -- Access
authentication_required (req: WGI_REQUEST): BOOLEAN
authentication_required (req: WSF_REQUEST): BOOLEAN
do
Result := True
end
feature -- Execution
execute_unauthorized (a_hdl_context: APP_REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_unauthorized (a_hdl_context: APP_REQUEST_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
local
s: STRING
lst: LIST [STRING]
@@ -52,16 +52,16 @@ feature -- Execution
res.write_string ("Unauthorized")
end
execute_application (ctx: APP_REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_application (ctx: APP_REQUEST_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
local
l_full: BOOLEAN
h: EWF_HEADER
h: WSF_HEADER
l_login: STRING_8
s: STRING
content_type_supported: ARRAY [STRING]
l_format_id: INTEGER
do
content_type_supported := <<{HTTP_CONSTANTS}.json_app, {HTTP_CONSTANTS}.xml_text, {HTTP_CONSTANTS}.plain_text>>
content_type_supported := <<{HTTP_CONSTANTS}.application_json, {HTTP_CONSTANTS}.text_xml, {HTTP_CONSTANTS}.text_plain>>
l_format_id := ctx.request_format_id ("format", content_type_supported)
if authenticated (ctx) then
l_full := attached ctx.query_parameter ("details") as v and then v.is_case_insensitive_equal ("true")

View File

@@ -32,17 +32,17 @@ feature {NONE} -- Initialization
feature -- Access
authentication_required (req: WGI_REQUEST): BOOLEAN
authentication_required (req: WSF_REQUEST): BOOLEAN
do
end
feature -- Execution
execute_application (ctx: APP_REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_application (ctx: APP_REQUEST_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
local
s: STRING
h: EWF_HEADER
h: WSF_HEADER
do
create h.make
h.put_content_type_text_plain

View File

@@ -68,17 +68,17 @@ feature {NONE} -- Handlers
feature -- Execution
execute (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
do
request_count := request_count + 1
Precursor (req, res)
end
execute_default (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
local
rqst_uri: detachable STRING
l_path_info: detachable STRING
h: EWF_HEADER
h: WSF_HEADER
s: STRING
l_redir_url: STRING
do
@@ -96,6 +96,8 @@ feature -- Execution
res.write_string (s)
end
request_count: INTEGER
-- execute_rescue (ctx: like new_request_context)
-- -- Execute the default rescue behavior
-- do
@@ -106,7 +108,7 @@ feature -- Implementation
-- execute_exception_trace (ctx: like new_request_context)
-- local
-- h: EWF_HEADER
-- h: WSF_HEADER
-- s: STRING
-- do
-- create h.make
@@ -121,7 +123,7 @@ feature -- Implementation
-- exit_with_code (-1)
-- end
execute_exit_application (ctx: APP_REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_exit_application (ctx: APP_REQUEST_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
local
s: STRING
do

View File

@@ -2,7 +2,7 @@ deferred class
REST_APPLICATION_GATEWAY
inherit
WGI_APPLICATION
WSF_APPLICATION
feature -- Access

View File

@@ -2,7 +2,7 @@ deferred class
REST_APPLICATION_GATEWAY
inherit
WGI_APPLICATION
WSF_APPLICATION
feature -- Access

View File

@@ -2,7 +2,7 @@ deferred class
REST_APPLICATION_GATEWAY
inherit
WGI_APPLICATION
WSF_APPLICATION
feature -- Access

View File

@@ -23,7 +23,7 @@ feature {NONE} -- Initialization
feature {NONE} -- Implementation
wgi_value_iteration_to_string (v: ITERABLE [WGI_VALUE]; using_pre: BOOLEAN): STRING_8
wgi_value_iteration_to_string (v: ITERABLE [WSF_VALUE]; using_pre: BOOLEAN): STRING_8
do
create Result.make (100)
if using_pre then

View File

@@ -9,7 +9,7 @@ deferred class
feature -- Helpers
send_error (a_path: STRING; a_error_id: INTEGER; a_error_name: STRING; a_error_message: detachable STRING; ctx: APP_REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
send_error (a_path: STRING; a_error_id: INTEGER; a_error_name: STRING; a_error_message: detachable STRING; ctx: APP_REQUEST_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
local
s: STRING
i,nb: INTEGER

View File

@@ -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"/>

View File

@@ -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"/>

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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]

View File

@@ -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

View File

@@ -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

View File

@@ -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]

View File

@@ -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

View File

@@ -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