diff --git a/draft/library/server/request/rest/src/contrib/doc/rest_api_documentation.e b/draft/library/server/request/rest/src/contrib/doc/rest_api_documentation.e deleted file mode 100644 index 285683f9..00000000 --- a/draft/library/server/request/rest/src/contrib/doc/rest_api_documentation.e +++ /dev/null @@ -1,327 +0,0 @@ -note - description: "Summary description for {REST_API_DOCUMENTATION}." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - REST_API_DOCUMENTATION [C -> REST_REQUEST_HANDLER_CONTEXT] - -inherit - REST_REQUEST_HANDLER [C] - -create - make - -feature {NONE} -- Initialization - - make (a_router: like router; a_base_doc_url: like base_doc_url) - do - router := a_router - base_doc_url := a_base_doc_url - description := "Technical documention for the API" - end - -feature {NONE} -- Access: Implementation - - router: REST_REQUEST_ROUTER [REST_REQUEST_HANDLER [C], C] - - base_doc_url: READABLE_STRING_8 - -feature -- Access - - authentication_required (req: WSF_REQUEST): BOOLEAN - do - end - - resource_value (ctx: C): detachable READABLE_STRING_32 - do - if attached {WSF_STRING} ctx.item ("resource") as s then - Result := s.value - end - end - -feature -- Execution - - execute_application (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) - local - rep: like new_html_page - s: STRING - rq: detachable REST_REQUEST_HANDLER [C] - rq_resource: detachable READABLE_STRING_GENERAL --- l_dft_format_name: detachable STRING - hdl_cursor: like router.new_cursor - do - rep := new_html_page - rep.headers.put_content_type_text_html - create s.make_empty - - if - attached resource_value (ctx) as l_resource - then - from - hdl_cursor := router.new_cursor - until - hdl_cursor.after or rq /= Void - loop - if hdl_cursor.item.resource.same_string_general (l_resource) then - rq := hdl_cursor.item.handler - rq_resource := l_resource - end - hdl_cursor.forth - end - end --- if a_args /= Void and then not a_args.is_empty then --- rq := router.handler_by_path (a_args) --- if rq = Void then --- rq := handler_manager.smart_handler_by_path (a_args) ----- if attached {REST_REQUEST_GROUP_HANDLER} rq as grp then ----- rq := grp.handlers.handler_by_path (a_args) ----- end --- end --- if --- rq /= Void and then --- attached rq.path_information (a_args) as l_info --- then --- l_dft_format_name := l_info.format --- end --- end - - - if rq /= Void and then rq_resource /= Void then - rep.set_big_title ("API: Technical documentation for ["+ rq_resource.as_string_8 +"]") - - s.append_string ("
") - s.append_string ("

") - - s.append_string (".. Show all features ..") - s.append_string ("

%N") - - process_request_handler_doc (rq, rq_resource.as_string_8, s, ctx, req, res, Void) - else - rep.set_big_title ("API: Technical documentation") - - from - hdl_cursor := router.new_cursor - until - hdl_cursor.after - loop - if attached hdl_cursor.item as l_item then - rq := l_item.handler - rep.add_shortcut (l_item.resource) - s.append ("") - process_request_handler_doc (rq, l_item.resource, s, ctx, req, res, Void) - hdl_cursor.forth - end - end - end - rep.set_body (s) - rep.send (res) - rep.recycle - end - - 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 - l_uri_tpl: URI_TEMPLATE - do - s := buf - - if a_dft_format /= Void then - if rq.supported_format_names.has (a_dft_format) then - l_dft_format_name := a_dft_format - end - end - - s.append_string ("
") - s.append_string ("

"+ a_resource +"

") - s.append_string ("
") --- if rq.hidden (req) then --- s.append_string ("
This feature is hidden
%N") --- else - if attached rq.description as desc then - s.append_string ("
" + desc + "
") - end --- if attached {REST_REQUEST_GROUP_HANDLER} rq as grp then --- s.append_string ("
Handler: ") --- if attached grp.handlers.new_cursor as l_handlers_cursor then --- from - --- until --- l_handlers_cursor.after --- loop --- s.append_string (" ") --- s.append_string (""+ l_handlers_cursor.item.path +"") --- l_handlers_cursor.forth --- end --- end --- s.append_string ("
") --- end - if attached rq.supported_format_names as l_formats and then not l_formats.is_empty then - s.append_string ("
Supported formats: ") - if attached l_formats.new_cursor as l_formats_cursor then - from - - until - l_formats_cursor.after - loop - s.append_string (" ") - s.append_string (""+ l_formats_cursor.item +"") - l_formats_cursor.forth - end - end - s.append_string ("
") - end - if attached rq.supported_request_method_names as l_methods and then not l_methods.is_empty then - s.append_string ("
Supported request methods: ") - if attached l_methods.new_cursor as l_methods_cursor then - from - - until - l_methods_cursor.after - loop - s.append_string (" ") - s.append_string (l_methods_cursor.item) - l_methods_cursor.forth - end - end - s.append_string ("
") - end - s.append_string ("
Authentication required: " + rq.authentication_required (req).out + "
") - if attached {REST_REQUEST_URI_TEMPLATE_ROUTER_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT], REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT]} router as l_uri_template_router then - create l_uri_tpl.make (a_resource) - if attached l_uri_tpl.query_variable_names as l_query_variable_names and then not l_query_variable_names.is_empty then - s.append_string ("
Query parameters: ") --- s.append_string (rq.path) - from - l_query_variable_names.start - until - l_query_variable_names.after - loop - if l_query_variable_names.isfirst then - s.append_string ("?") - else - s.append_string ("&") - end - if attached l_query_variable_names.item as l_query_param then - s.append_string ("" + l_query_param + "") - s.append_string ("=" + l_query_param + "") - end - l_query_variable_names.forth - end - s.append_string ("
%N") - end - if attached l_uri_tpl.path_variable_names as l_path_variable_names and then not l_path_variable_names.is_empty then - s.append_string ("
Path Segment parameters: ") --- s.append_string (rq.path) - from - l_path_variable_names.start - until - l_path_variable_names.after - loop - if attached l_path_variable_names.item as l_seg_param then - s.append_string ("{" + l_seg_param + "}") - end - l_path_variable_names.forth - end - s.append_string ("
%N") - end - - end --- if attached rq._parameters as l_uri_params and then not l_uri_params.is_empty then --- s.append_string ("
URI Template: ") --- s.append_string (rq.path) --- if attached l_uri_params.new_cursor as l_uri_params_cursor then --- from - --- until --- l_uri_params_cursor.after --- loop --- if attached l_uri_params_cursor.item as l_uri_param then --- s.append_string ("/" + l_uri_param.name + "") --- s.append_string ("/{" + l_uri_param.name + "}") --- end --- l_uri_params_cursor.forth --- end --- end --- s.append_string ("
%N") --- end --- if attached rq.parameters as l_params and then not l_params.is_empty then --- s.append_string ("
Parameters: ") - --- --| show form only if we have a default format --- if l_dft_format_name = Void then --- s.append_string ("to test the parameter(s), please first select a supported format.%N") --- else --- if rq.method_post_supported then --- s.append_string ("
%N") --- else --- s.append_string ("%N") --- end --- end --- s.append_string ("
    ") --- if attached l_params.new_cursor as l_params_cursor then --- from - --- until --- l_params_cursor.after --- loop --- if attached l_params_cursor.item as l_param then --- s.append_string ("
  • " + l_param.name + "") --- if l_param.optional then --- s.append_string (" (Optional)") --- end --- if attached l_param.description as l_param_desc then --- s.append_string (": " + l_param_desc + "") --- end --- if l_dft_format_name /= Void then --- s.append (" ") --- end --- s.append_string ("
  • ") --- end --- l_params_cursor.forth --- end --- end - --- if l_dft_format_name /= Void then --- s.append_string ("") --- s.append_string ("") --- end --- s.append_string ("
") --- else --- if l_dft_format_name /= Void then --- s.append_string ("Test "+ a_resource + "." + l_dft_format_name + "") --- else --- s.append_string ("Test "+ a_resource +"") --- end --- end - s.append_string ("
%N") --- end - s.append_string ("
%N") -- inner - end - -feature -- Access - - new_html_page: REST_API_DOCUMENTATION_HTML_PAGE - do - create Result.make ("API Documentation") - end - -note - copyright: "Copyright (c) 1984-2012, 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 diff --git a/draft/library/server/request/rest/src/rest_request_agent_handler.e b/draft/library/server/request/rest/src/rest_request_agent_handler.e index f0a43944..f84ddc63 100644 --- a/draft/library/server/request/rest/src/rest_request_agent_handler.e +++ b/draft/library/server/request/rest/src/rest_request_agent_handler.e @@ -1,46 +1,14 @@ -note - description: "Summary description for REST_REQUEST_AGENT_HANDLER." - author: "" - date: "$Date$" - revision: "$Revision$" - class - REST_REQUEST_AGENT_HANDLER [C -> REST_REQUEST_HANDLER_CONTEXT] + REST_REQUEST_AGENT_HANDLER inherit - WSF_AGENT_HANDLER [C] - rename - execute as execute_application - end - - REST_REQUEST_HANDLER [C] - select - execute - end + WSF_AGENT_URI_TEMPLATE_HANDLER create make -feature -- status - - authentication_required (req: WSF_REQUEST): BOOLEAN - do - Result := internal_authentication_required - end - -feature -- Element change - - set_authentication_required (b: like authentication_required) - do - internal_authentication_required := b - end - -feature {NONE} -- Implementation - - internal_authentication_required: BOOLEAN - -;note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" +note + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/draft/library/server/request/rest/src/rest_request_handler.e b/draft/library/server/request/rest/src/rest_request_handler.e index bbf799bf..ed33bf59 100644 --- a/draft/library/server/request/rest/src/rest_request_handler.e +++ b/draft/library/server/request/rest/src/rest_request_handler.e @@ -5,10 +5,10 @@ note revision: "$Revision$" deferred class - REST_REQUEST_HANDLER [C -> REST_REQUEST_HANDLER_CONTEXT] + REST_REQUEST_HANDLER inherit - WSF_HANDLER [C] + WSF_URI_TEMPLATE_HANDLER WSF_HANDLER_HELPER @@ -34,7 +34,7 @@ feature -- Element change feature -- Execution - execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute (ctx: REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) -- Execute request handler do if request_method_name_supported (req.request_method) then @@ -52,26 +52,26 @@ feature -- Execution execute_rescue (ctx, req, res) end - execute_application (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_application (ctx: REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) deferred end - pre_execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + pre_execute (ctx: REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) do end - post_execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + post_execute (ctx: REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) do end - execute_rescue (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_rescue (ctx: REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) do post_execute (ctx, req, res) rescue --| Just in case, the rescue is raising other exceptions ... end - execute_unauthorized (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_unauthorized (ctx: REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) do res.put_header ({HTTP_STATUS_CODE}.unauthorized, Void) res.put_string ("Unauthorized") @@ -79,7 +79,7 @@ feature -- Execution feature -- Auth - authenticated (ctx: C): BOOLEAN + authenticated (ctx: REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT): BOOLEAN -- Is authenticated? do --| To redefine if needed diff --git a/draft/library/server/request/rest/src/rest_request_router.e b/draft/library/server/request/rest/src/rest_request_router.e deleted file mode 100644 index 80a74f21..00000000 --- a/draft/library/server/request/rest/src/rest_request_router.e +++ /dev/null @@ -1,23 +0,0 @@ -note - description: "Summary description for {REST_REQUEST_ROUTER}." - author: "" - date: "$Date$" - revision: "$Revision$" - -deferred class - REST_REQUEST_ROUTER [H -> REST_REQUEST_HANDLER [C], C -> REST_REQUEST_HANDLER_CONTEXT] - -inherit - WSF_ROUTER [H, C] - -;note - copyright: "Copyright (c) 1984-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 diff --git a/draft/library/server/request/rest/src/rest_service.e b/draft/library/server/request/rest/src/rest_service.e index 1a395664..419f25f3 100644 --- a/draft/library/server/request/rest/src/rest_service.e +++ b/draft/library/server/request/rest/src/rest_service.e @@ -8,10 +8,10 @@ deferred class REST_SERVICE inherit - REST_SERVICE_I [REST_REQUEST_HANDLER [REST_REQUEST_HANDLER_CONTEXT], REST_REQUEST_HANDLER_CONTEXT] + REST_SERVICE_I note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/draft/library/server/request/rest/src/rest_service_i.e b/draft/library/server/request/rest/src/rest_service_i.e index 198b1d3f..dac1cf91 100644 --- a/draft/library/server/request/rest/src/rest_service_i.e +++ b/draft/library/server/request/rest/src/rest_service_i.e @@ -5,21 +5,13 @@ note revision: "$Revision$" deferred class - REST_SERVICE_I [H -> REST_REQUEST_HANDLER [C], C -> REST_REQUEST_HANDLER_CONTEXT] + REST_SERVICE_I inherit - WSF_ROUTED_SERVICE_I [H, C] - redefine - router - end - -feature -- Setup - - router: REST_REQUEST_ROUTER [H, C] - -- Request router + WSF_URI_TEMPLATE_ROUTED_SERVICE ;note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/draft/library/server/request/rest/src/uri/rest_request_uri_handler.e b/draft/library/server/request/rest/src/uri/rest_request_uri_handler.e deleted file mode 100644 index 1d162808..00000000 --- a/draft/library/server/request/rest/src/uri/rest_request_uri_handler.e +++ /dev/null @@ -1,24 +0,0 @@ -note - description: "Summary description for {DEFAULT_REST_REQUEST_URI_HANDLER}." - author: "" - date: "$Date$" - revision: "$Revision$" - -deferred class - REST_REQUEST_URI_HANDLER - -inherit - REST_REQUEST_HANDLER [REST_REQUEST_URI_HANDLER_CONTEXT] - - -;note - copyright: "Copyright (c) 1984-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 diff --git a/draft/library/server/request/rest/src/uri/rest_request_uri_router.e b/draft/library/server/request/rest/src/uri/rest_request_uri_router.e deleted file mode 100644 index 2bb6612c..00000000 --- a/draft/library/server/request/rest/src/uri/rest_request_uri_router.e +++ /dev/null @@ -1,40 +0,0 @@ -note - description: "Summary description for {DEFAULT_REST_REQUEST_URI_ROUTER}." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - REST_REQUEST_URI_ROUTER - -inherit - REST_REQUEST_URI_ROUTER_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_HANDLER_CONTEXT], REST_REQUEST_URI_HANDLER_CONTEXT] - redefine - map_agent_with_request_methods - end - -create - make - -feature -- Mapping - - 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 WSF_ROUTER_METHODS) - local - h: REST_REQUEST_AGENT_HANDLER [REST_REQUEST_URI_HANDLER_CONTEXT] - do - create h.make (a_action) - map_with_request_methods (a_id, h, rqst_methods) - end - -note - copyright: "Copyright (c) 1984-2012, 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 diff --git a/draft/library/server/request/rest/src/uri/rest_request_uri_router_i.e b/draft/library/server/request/rest/src/uri/rest_request_uri_router_i.e deleted file mode 100644 index 07fc0bbb..00000000 --- a/draft/library/server/request/rest/src/uri/rest_request_uri_router_i.e +++ /dev/null @@ -1,36 +0,0 @@ -note - description: "Summary description for {REST_REQUEST_URI_ROUTER}." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - REST_REQUEST_URI_ROUTER_I [H -> REST_REQUEST_HANDLER [C], C -> REST_REQUEST_URI_HANDLER_CONTEXT create make end] - -inherit - WSF_URI_ROUTER_I [H, C] - - REST_REQUEST_ROUTER [H, C] - - -create - make - -feature -- Mapping - --- map_agent_with_request_methods (a_id: READABLE_STRING_8; a_action: like {REST_REQUEST_AGENT_HANDLER}.action; rqst_methods: detachable ARRAY [READABLE_STRING_8]) --- do --- Precursor (a_id, a_action, rqst_methods) --- end - -note - copyright: "Copyright (c) 1984-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 diff --git a/draft/library/server/request/rest/src/uri/rest_request_uri_routing_handler.e b/draft/library/server/request/rest/src/uri/rest_request_uri_routing_handler.e deleted file mode 100644 index 374df903..00000000 --- a/draft/library/server/request/rest/src/uri/rest_request_uri_routing_handler.e +++ /dev/null @@ -1,33 +0,0 @@ -note - description: "Summary description for {DEFAULT_REST_REQUEST_URI_ROUTING_HANDLER}." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - REST_REQUEST_URI_ROUTING_HANDLER - -inherit - REST_REQUEST_URI_ROUTING_HANDLER_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_HANDLER_CONTEXT], REST_REQUEST_URI_HANDLER_CONTEXT] - redefine - router - end - -create - make - -feature {NONE} -- Routing - - router: REST_REQUEST_URI_ROUTER - -;note - copyright: "Copyright (c) 1984-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 diff --git a/draft/library/server/request/rest/src/uri/rest_request_uri_routing_handler_i.e b/draft/library/server/request/rest/src/uri/rest_request_uri_routing_handler_i.e deleted file mode 100644 index b05571ba..00000000 --- a/draft/library/server/request/rest/src/uri/rest_request_uri_routing_handler_i.e +++ /dev/null @@ -1,64 +0,0 @@ -note - description: "Summary description for {WSF_ROUTING_HANDLER }." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - REST_REQUEST_URI_ROUTING_HANDLER_I [H -> REST_REQUEST_HANDLER [C], - C -> REST_REQUEST_URI_HANDLER_CONTEXT create make end] - -inherit - WSF_URI_ROUTING_HANDLER_I [H, C] - redefine - router, - execute - end - - REST_REQUEST_HANDLER [C] - undefine - execute - end - -create - make - -feature -- Status report - - authentication_required (req: WSF_REQUEST): BOOLEAN - do - Result := internal_authentication_required - end - -feature {NONE} -- Implementation - - internal_authentication_required: BOOLEAN - -feature -- Execution - - execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) - do - Precursor {WSF_URI_ROUTING_HANDLER_I} (ctx, req, res) - end - - execute_application (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) - do - check should_not_occur: False end - end - - -feature {NONE} -- Routing - - router: REST_REQUEST_URI_ROUTER_I [H, C] - -;note - copyright: "Copyright (c) 1984-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 diff --git a/draft/library/server/request/rest/src/uri/rest_uri_service.e b/draft/library/server/request/rest/src/uri/rest_uri_service.e deleted file mode 100644 index 8d86f861..00000000 --- a/draft/library/server/request/rest/src/uri/rest_uri_service.e +++ /dev/null @@ -1,30 +0,0 @@ -note - description: "Summary description for {DEFAULT_REST_URI_SERVICE}." - author: "" - date: "$Date$" - revision: "$Revision$" - -deferred class - REST_URI_SERVICE - -inherit - REST_SERVICE_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_HANDLER_CONTEXT], REST_REQUEST_URI_HANDLER_CONTEXT] - redefine - router - end - -feature -- Router - - router: REST_REQUEST_URI_ROUTER - -;note - copyright: "Copyright (c) 1984-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 diff --git a/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_handler.e b/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_handler.e index 59198577..fd4bdbcb 100644 --- a/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_handler.e +++ b/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_handler.e @@ -8,11 +8,11 @@ deferred class REST_REQUEST_URI_TEMPLATE_HANDLER inherit - REST_REQUEST_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT] + REST_REQUEST_HANDLER ;note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_router.e b/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_router.e deleted file mode 100644 index 210080e2..00000000 --- a/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_router.e +++ /dev/null @@ -1,41 +0,0 @@ -note - description: "Summary description for {DEFAULT_REST_REQUEST_URI_TEMPLATE_ROUTER}." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - REST_REQUEST_URI_TEMPLATE_ROUTER - -inherit - REST_REQUEST_URI_TEMPLATE_ROUTER_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT], REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT] - redefine - map_agent_with_request_methods - end - -create - make, - make_with_base_url - -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: WSF_REQUEST; res: WSF_RESPONSE]]; - rqst_methods: detachable WSF_ROUTER_METHODS) - local - h: REST_REQUEST_AGENT_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT] - do - create h.make (a_action) - map_with_request_methods (a_id, h, rqst_methods) - end - -note - copyright: "Copyright (c) 1984-2012, 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 diff --git a/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_router_i.e b/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_router_i.e deleted file mode 100644 index f8daf292..00000000 --- a/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_router_i.e +++ /dev/null @@ -1,29 +0,0 @@ -note - description: "Summary description for {REST_REQUEST_URI_TEMPLATE_ROUTER}." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - REST_REQUEST_URI_TEMPLATE_ROUTER_I [H -> REST_REQUEST_HANDLER [C], C -> REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT create make end] - -inherit - WSF_URI_TEMPLATE_ROUTER_I [H, C] - - REST_REQUEST_ROUTER [H, C] - -create - make, - make_with_base_url - -note - copyright: "Copyright (c) 1984-2012, 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 diff --git a/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_routing_handler.e b/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_routing_handler.e deleted file mode 100644 index 4888c271..00000000 --- a/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_routing_handler.e +++ /dev/null @@ -1,34 +0,0 @@ -note - description: "Summary description for {DEFAULT_REST_REQUEST_URI_TEMPLATE_ROUTING_HANDLER}." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - REST_REQUEST_URI_TEMPLATE_ROUTING_HANDLER - -inherit - REST_REQUEST_URI_TEMPLATE_ROUTING_HANDLER_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT], REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT] - redefine - router - end - -create - make, - make_with_base_url - -feature {NONE} -- Routing - - router: REST_REQUEST_URI_TEMPLATE_ROUTER - -;note - copyright: "Copyright (c) 1984-2012, 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 diff --git a/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_routing_handler_i.e b/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_routing_handler_i.e deleted file mode 100644 index 43bd5ea9..00000000 --- a/draft/library/server/request/rest/src/uri_template/rest_request_uri_template_routing_handler_i.e +++ /dev/null @@ -1,66 +0,0 @@ -note - description: "Summary description for {WSF_ROUTING_HANDLER }." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - REST_REQUEST_URI_TEMPLATE_ROUTING_HANDLER_I [H -> REST_REQUEST_HANDLER [C], - C -> REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT create make end] - -inherit - WSF_URI_TEMPLATE_ROUTING_HANDLER_I [H, C] - redefine - router, - execute - end - - REST_REQUEST_HANDLER [C] - undefine - execute - end - -create - make, - make_with_base_url - -feature -- Status report - - authentication_required (req: WSF_REQUEST): BOOLEAN - do - Result := internal_authentication_required - end - -feature {NONE} -- Implementation - - internal_authentication_required: BOOLEAN - -feature -- Execution - - execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) - do - pre_execute (ctx, req, res) - Precursor {WSF_URI_TEMPLATE_ROUTING_HANDLER_I} (ctx, req, res) - post_execute (ctx, req, res) - end - - execute_application (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) - do - check should_not_occur: False end - end - -feature {NONE} -- Routing - - router: REST_REQUEST_URI_TEMPLATE_ROUTER_I [H, C] - -;note - copyright: "Copyright (c) 1984-2012, 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 diff --git a/draft/library/server/request/rest/src/uri_template/rest_uri_template_service.e b/draft/library/server/request/rest/src/uri_template/rest_uri_template_service.e index d8c5bb89..d77e2ff7 100644 --- a/draft/library/server/request/rest/src/uri_template/rest_uri_template_service.e +++ b/draft/library/server/request/rest/src/uri_template/rest_uri_template_service.e @@ -8,17 +8,10 @@ deferred class REST_URI_TEMPLATE_SERVICE inherit - REST_SERVICE_I [REST_REQUEST_HANDLER [REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT], REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT] - redefine - router - end - -feature -- Router - - router: REST_REQUEST_URI_TEMPLATE_ROUTER + REST_SERVICE_I ;note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/examples/filter/src/filter/authentication_filter.e b/examples/filter/src/filter/authentication_filter.e index 3f4809bc..949ff380 100644 --- a/examples/filter/src/filter/authentication_filter.e +++ b/examples/filter/src/filter/authentication_filter.e @@ -5,16 +5,27 @@ note revision: "$Revision$" class - AUTHENTICATION_FILTER [C -> WSF_URI_TEMPLATE_HANDLER_CONTEXT] + AUTHENTICATION_FILTER inherit - WSF_FILTER_HANDLER [C] + WSF_FILTER_HANDLER [WSF_URI_TEMPLATE_HANDLER] SHARED_DATABASE_API + WSF_URI_TEMPLATE_HANDLER + + WSF_RESOURCE_HANDLER_HELPER +-- redefine +-- do_get +-- end + + SHARED_DATABASE_API + + SHARED_EJSON + feature -- Basic operations - execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute (req: WSF_REQUEST; res: WSF_RESPONSE) -- Execute the filter local l_auth: HTTP_AUTHORIZATION @@ -24,15 +35,24 @@ feature -- Basic operations attached Db_access.users.item (1) as l_user and then (attached l_auth.login as l_auth_login and then l_auth_login.is_equal (l_user.name) and attached l_auth.password as l_auth_password and then l_auth_password.is_equal (l_user.password)) then - execute_next (ctx, req, res) + execute_next (req, res) else - handle_unauthorized ("Unauthorized", ctx, req, res) + handle_unauthorized ("Unauthorized", req, res) + end + end + +feature -- Filter + + execute_next (req: WSF_REQUEST; res: WSF_RESPONSE) + do + if attached next as n then + n.execute (req, res) end end feature {NONE} -- Implementation - handle_unauthorized (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + handle_unauthorized (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE) -- Handle forbidden. local h: HTTP_HEADER diff --git a/examples/filter/src/filter_server.e b/examples/filter/src/filter_server.e index b956fc16..c407cfc6 100644 --- a/examples/filter/src/filter_server.e +++ b/examples/filter/src/filter_server.e @@ -10,7 +10,7 @@ class inherit ANY - WSF_URI_TEMPLATE_FILTERED_SERVICE + WSF_FILTERED_SERVICE WSF_HANDLER_HELPER @@ -34,18 +34,21 @@ feature {NONE} -- Initialization create_filter -- Create `filter' local - l_router: WSF_URI_TEMPLATE_ROUTER - l_authentication_filter: AUTHENTICATION_FILTER [WSF_URI_TEMPLATE_HANDLER_CONTEXT] - l_user_filter: USER_HANDLER [WSF_URI_TEMPLATE_HANDLER_CONTEXT] - l_user_handler: WSF_HANDLER [WSF_URI_TEMPLATE_HANDLER_CONTEXT] - l_routing_filter: WSF_ROUTING_FILTER [WSF_HANDLER [WSF_URI_TEMPLATE_HANDLER_CONTEXT], WSF_URI_TEMPLATE_HANDLER_CONTEXT] + l_router: WSF_ROUTER + l_authentication_filter_hdl: AUTHENTICATION_FILTER + l_user_filter: USER_HANDLER + l_user_handler: WSF_URI_TEMPLATE_HANDLER +-- l_routing_hdl: WSF_URI_TEMPLATE_ROUTING_HANDLER --[WSF_HANDLER [WSF_URI_TEMPLATE_HANDLER_CONTEXT], WSF_URI_TEMPLATE_HANDLER_CONTEXT] + l_routing_filter: WSF_ROUTING_FILTER do create l_router.make (1) - create l_authentication_filter + create l_authentication_filter_hdl create l_user_filter - l_authentication_filter.set_next (l_user_filter) - l_user_handler := l_authentication_filter - l_router.map_with_request_methods ("/user/{userid}", l_user_handler, << "GET" >>) + l_authentication_filter_hdl.set_next (l_user_filter) + l_user_handler := l_authentication_filter_hdl + l_router.handle_with_request_methods ("/user/{userid}", l_user_handler, l_router.methods_get) +-- l_router.map_with_request_methods ("/user/{userid}", l_user_handler, << "GET" >>) +-- create l_routing_hdl.make_with_router (l_router) create l_routing_filter.make (l_router) l_routing_filter.set_execute_default_action (agent execute_default) filter := l_routing_filter diff --git a/examples/filter/src/resource/user_handler.e b/examples/filter/src/resource/user_handler.e index f6e9a7c1..dad66c18 100644 --- a/examples/filter/src/resource/user_handler.e +++ b/examples/filter/src/resource/user_handler.e @@ -5,12 +5,14 @@ note revision: "$Revision$" class - USER_HANDLER [C -> WSF_HANDLER_CONTEXT] + USER_HANDLER inherit - WSF_FILTER_HANDLER [C] + WSF_FILTER_HANDLER [WSF_URI_TEMPLATE_HANDLER] - WSF_RESOURCE_HANDLER_HELPER [C] + WSF_URI_TEMPLATE_HANDLER + + WSF_RESOURCE_HANDLER_HELPER redefine do_get end @@ -21,13 +23,13 @@ inherit feature -- Basic operations - execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute (req: WSF_REQUEST; res: WSF_RESPONSE) -- Execute request handler do - execute_methods (ctx, req, res) + execute_methods (req, res) end - do_get (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + do_get (req: WSF_REQUEST; res: WSF_RESPONSE) -- Using GET to retrieve resource information. -- If the GET request is SUCCESS, we response with -- 200 OK, and a representation of the user @@ -39,16 +41,16 @@ feature -- Basic operations if attached req.orig_path_info as orig_path then id := get_user_id_from_path (orig_path) if attached retrieve_user (id) as l_user then - compute_response_get (ctx, req, res, l_user) + compute_response_get (req, res, l_user) else - handle_resource_not_found_response ("The following resource " + orig_path + " is not found ", ctx, req, res) + handle_resource_not_found_response ("The following resource " + orig_path + " is not found ", req, res) end end end feature {NONE} -- Implementation - compute_response_get (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE; l_user : USER) + compute_response_get (req: WSF_REQUEST; res: WSF_RESPONSE; l_user : USER) local h: HTTP_HEADER l_msg : STRING diff --git a/examples/restbucksCRUD/src/resource/order_handler.e b/examples/restbucksCRUD/src/resource/order_handler.e index 570484ae..600ba033 100644 --- a/examples/restbucksCRUD/src/resource/order_handler.e +++ b/examples/restbucksCRUD/src/resource/order_handler.e @@ -5,10 +5,23 @@ note revision: "$Revision$" class - ORDER_HANDLER [C -> WSF_HANDLER_CONTEXT] + ORDER_HANDLER inherit - WSF_HANDLER [C] - WSF_RESOURCE_HANDLER_HELPER [C] + WSF_URI_HANDLER + rename + execute as uri_execute, + new_mapping as new_uri_mapping + end + + WSF_URI_TEMPLATE_HANDLER + rename + execute as uri_template_execute, + new_mapping as new_uri_template_mapping + select + new_uri_template_mapping + end + + WSF_RESOURCE_HANDLER_HELPER redefine do_get, do_post, @@ -22,10 +35,16 @@ inherit feature -- execute - execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE) -- Execute request handler do - execute_methods (ctx, req, res) + execute_methods (req, res) + end + + uri_template_execute (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) + -- Execute request handler + do + execute_methods (req, res) end feature -- API DOC @@ -34,7 +53,7 @@ feature -- API DOC feature -- HTTP Methods - do_get (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + do_get (req: WSF_REQUEST; res: WSF_RESPONSE) -- Using GET to retrieve resource information. -- If the GET request is SUCCESS, we response with -- 200 OK, and a representation of the order @@ -49,12 +68,12 @@ feature -- HTTP Methods id := get_order_id_from_path (orig_path) if attached retrieve_order (id) as l_order then if is_conditional_get (req, l_order) then - handle_resource_not_modified_response ("The resource" + orig_path + "does not change", ctx, req, res) + handle_resource_not_modified_response ("The resource" + orig_path + "does not change", req, res) else - compute_response_get (ctx, req, res, l_order) + compute_response_get (req, res, l_order) end else - handle_resource_not_found_response ("The following resource" + orig_path + " is not found ", ctx, req, res) + handle_resource_not_found_response ("The following resource" + orig_path + " is not found ", req, res) end end end @@ -74,7 +93,7 @@ feature -- HTTP Methods end end - compute_response_get (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE; l_order : ORDER) + compute_response_get (req: WSF_REQUEST; res: WSF_RESPONSE; l_order : ORDER) local h: HTTP_HEADER l_msg : STRING @@ -96,7 +115,7 @@ feature -- HTTP Methods end end - do_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + do_put (req: WSF_REQUEST; res: WSF_RESPONSE) -- Updating a resource with PUT -- A successful PUT request will not create a new resource, instead it will -- change the state of the resource identified by the current uri. @@ -120,16 +139,16 @@ feature -- HTTP Methods if is_valid_to_update(l_order) then if is_conditional_put (req, l_order) then update_order( l_order) - compute_response_put (ctx, req, res, l_order) + compute_response_put (req, res, l_order) else - handle_precondition_fail_response ("", ctx, req, res) + handle_precondition_fail_response ("", req, res) end else --| FIXME: Here we need to define the Allow methods - handle_resource_conflict_response (l_put +"%N There is conflict while trying to update the order, the order could not be update in the current state", ctx, req, res) + handle_resource_conflict_response (l_put +"%N There is conflict while trying to update the order, the order could not be update in the current state", req, res) end else - handle_bad_request_response (l_put +"%N is not a valid ORDER, maybe the order does not exist in the system", ctx, req, res) + handle_bad_request_response (l_put +"%N is not a valid ORDER, maybe the order does not exist in the system", req, res) end end end @@ -153,7 +172,7 @@ feature -- HTTP Methods end - compute_response_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE; l_order : ORDER) + compute_response_put (req: WSF_REQUEST; res: WSF_RESPONSE; l_order : ORDER) local h: HTTP_HEADER joc : JSON_ORDER_CONVERTER @@ -179,7 +198,7 @@ feature -- HTTP Methods end - do_delete (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + do_delete (req: WSF_REQUEST; res: WSF_RESPONSE) -- Here we use DELETE to cancel an order, if that order is in state where -- it can still be canceled. -- 200 if is ok @@ -194,18 +213,18 @@ feature -- HTTP Methods if db_access.orders.has_key (id) then if is_valid_to_delete (id) then delete_order( id) - compute_response_delete (ctx, req, res) + compute_response_delete (req, res) else --| FIXME: Here we need to define the Allow methods - handle_method_not_allowed_response (orig_path + "%N There is conflict while trying to delete the order, the order could not be deleted in the current state", ctx, req, res) + handle_method_not_allowed_response (orig_path + "%N There is conflict while trying to delete the order, the order could not be deleted in the current state", req, res) end else - handle_resource_not_found_response (orig_path + " not found in this server", ctx, req, res) + handle_resource_not_found_response (orig_path + " not found in this server", req, res) end end end - compute_response_delete (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + compute_response_delete (req: WSF_REQUEST; res: WSF_RESPONSE) local h : HTTP_HEADER do @@ -218,7 +237,7 @@ feature -- HTTP Methods res.put_header_text (h.string) end - do_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + do_post (req: WSF_REQUEST; res: WSF_RESPONSE) -- Here the convention is the following. -- POST is used for creation and the server determines the URI -- of the created resource. @@ -233,13 +252,13 @@ feature -- HTTP Methods l_post := retrieve_data (req) if attached extract_order_request (l_post) as l_order then save_order (l_order) - compute_response_post (ctx, req, res, l_order) + compute_response_post (req, res, l_order) else - handle_bad_request_response (l_post +"%N is not a valid ORDER", ctx, req, res) + handle_bad_request_response (l_post +"%N is not a valid ORDER", req, res) end end - compute_response_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE; l_order : ORDER) + compute_response_post (req: WSF_REQUEST; res: WSF_RESPONSE; l_order : ORDER) local h: HTTP_HEADER l_msg : STRING diff --git a/examples/restbucksCRUD/src/restbucks_server.e b/examples/restbucksCRUD/src/restbucks_server.e index 79efc423..ad1beb4d 100644 --- a/examples/restbucksCRUD/src/restbucks_server.e +++ b/examples/restbucksCRUD/src/restbucks_server.e @@ -1,6 +1,5 @@ note - description : "Objects that ..." - author : "$Author$" + description : "REST Buck server" date : "$Date$" revision : "$Revision$" @@ -30,11 +29,11 @@ feature {NONE} -- Initialization setup_router local - order_handler: ORDER_HANDLER [WSF_URI_TEMPLATE_HANDLER_CONTEXT] + order_handler: ORDER_HANDLER do create order_handler - router.map_with_request_methods ("/order", order_handler, <<"POST">>) - router.map_with_request_methods ("/order/{orderid}", order_handler, <<"GET", "DELETE", "PUT">>) + router.handle_with_request_methods ("/order", order_handler, router.methods_POST) + router.handle_with_request_methods ("/order/{orderid}", order_handler, router.methods_GET + router.methods_DELETE + router.methods_PUT) end feature -- Execution diff --git a/examples/upload_image/src/image_uploader.e b/examples/upload_image/src/image_uploader.e index 0517c6a8..876870e7 100644 --- a/examples/upload_image/src/image_uploader.e +++ b/examples/upload_image/src/image_uploader.e @@ -10,8 +10,12 @@ class inherit ANY + WSF_ROUTED_SERVICE + WSF_URI_TEMPLATE_ROUTED_SERVICE + WSF_URI_ROUTED_SERVICE + WSF_DEFAULT_SERVICE create @@ -34,14 +38,14 @@ feature {NONE} -- Initialization setup_router -- Setup router local - www: WSF_FILE_SYSTEM_HANDLER [WSF_URI_TEMPLATE_HANDLER_CONTEXT] + www: WSF_FILE_SYSTEM_HANDLER do - router.map_agent ("/upload{?nb}", agent execute_upload) + map_uri_template_agent ("/upload{?nb}", agent execute_upload) create www.make (document_root) www.set_directory_index (<<"index.html">>) www.set_not_found_handler (agent execute_not_found) - router.map_with_request_methods ("{/path}{?query}", www, <<"GET">>) + router.handle_with_request_methods ("", www, router.methods_GET) end feature -- Configuration @@ -59,6 +63,8 @@ feature -- Configuration if Result [Result.count] = Operating_environment.directory_separator then Result := Result.substring (1, Result.count - 1) end + ensure + not Result.ends_with (Operating_environment.directory_separator.out) end files_root: READABLE_STRING_8 @@ -79,7 +85,7 @@ feature -- Execution res.redirect_now_with_content (req.script_url ("/"), "Redirection to " + req.script_url ("/"), "text/html") end - execute_not_found (uri: READABLE_STRING_8; ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_not_found (uri: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE) -- `uri' is not found, redirect to default page do res.redirect_now_with_content (req.script_url ("/"), uri + ": not found.%NRedirection to " + req.script_url ("/"), "text/html") diff --git a/library/server/wsf/router/wsf_handler_context.e b/library/server/wsf/router/context/wsf_handler_context.e similarity index 100% rename from library/server/wsf/router/wsf_handler_context.e rename to library/server/wsf/router/context/wsf_handler_context.e diff --git a/library/server/wsf/router/mapping/starts_with/wsf_starts_with_handler.e b/library/server/wsf/router/mapping/starts_with/wsf_starts_with_handler.e new file mode 100644 index 00000000..0da0fc96 --- /dev/null +++ b/library/server/wsf/router/mapping/starts_with/wsf_starts_with_handler.e @@ -0,0 +1,36 @@ +note + description: "Summary description for {WSF_STARTS_WITH_HANDLER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_STARTS_WITH_HANDLER + +inherit + WSF_HANDLER + +feature -- Execution + + execute (a_start_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE) + deferred + end + +feature {WSF_ROUTER} -- Mapping + + new_mapping (a_uri: READABLE_STRING_8): WSF_STARTS_WITH_MAPPING + do + create Result.make (a_uri, Current) + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/router/starts_with/wsf_starts_with_mapping.e b/library/server/wsf/router/mapping/starts_with/wsf_starts_with_mapping.e similarity index 96% rename from library/server/wsf/router/starts_with/wsf_starts_with_mapping.e rename to library/server/wsf/router/mapping/starts_with/wsf_starts_with_mapping.e index a71f2da8..5013aa56 100644 --- a/library/server/wsf/router/starts_with/wsf_starts_with_mapping.e +++ b/library/server/wsf/router/mapping/starts_with/wsf_starts_with_mapping.e @@ -1,5 +1,5 @@ note - description: "Summary description for EWF_URI_PATH." + description: "Summary description for EWF_STARTS_WITH_PATH." author: "" date: "$Date$" revision: "$Revision$" diff --git a/library/server/wsf/router/uri/wsf_agent_uri_handler.e b/library/server/wsf/router/mapping/uri/wsf_agent_uri_handler.e similarity index 100% rename from library/server/wsf/router/uri/wsf_agent_uri_handler.e rename to library/server/wsf/router/mapping/uri/wsf_agent_uri_handler.e diff --git a/library/server/wsf/router/uri/wsf_agent_uri_template_response_handler.e b/library/server/wsf/router/mapping/uri/wsf_agent_uri_template_response_handler.e similarity index 76% rename from library/server/wsf/router/uri/wsf_agent_uri_template_response_handler.e rename to library/server/wsf/router/mapping/uri/wsf_agent_uri_template_response_handler.e index e178ccf4..5909cb30 100644 --- a/library/server/wsf/router/uri/wsf_agent_uri_template_response_handler.e +++ b/library/server/wsf/router/mapping/uri/wsf_agent_uri_template_response_handler.e @@ -22,13 +22,13 @@ feature -- Initialization feature -- Access - action: FUNCTION [ANY, TUPLE [ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST], WSF_RESPONSE_MESSAGE] + action: FUNCTION [ANY, TUPLE [req: WSF_REQUEST], WSF_RESPONSE_MESSAGE] feature -- Execution - response (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST): WSF_RESPONSE_MESSAGE + response (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE do - Result := action.item ([ctx, req]) + Result := action.item ([req]) end note diff --git a/library/server/wsf/router/mapping/uri/wsf_uri_handler.e b/library/server/wsf/router/mapping/uri/wsf_uri_handler.e new file mode 100644 index 00000000..82037a52 --- /dev/null +++ b/library/server/wsf/router/mapping/uri/wsf_uri_handler.e @@ -0,0 +1,36 @@ +note + description: "Summary description for {EWF_ROUTER_URI_PATH_HANDLER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_URI_HANDLER + +inherit + WSF_HANDLER + +feature -- Execution + + execute (req: WSF_REQUEST; res: WSF_RESPONSE) + deferred + end + +feature {WSF_ROUTER} -- Mapping + + new_mapping (a_uri: READABLE_STRING_8): WSF_URI_MAPPING + do + create Result.make (a_uri, Current) + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/router/uri/wsf_uri_mapping.e b/library/server/wsf/router/mapping/uri/wsf_uri_mapping.e similarity index 100% rename from library/server/wsf/router/uri/wsf_uri_mapping.e rename to library/server/wsf/router/mapping/uri/wsf_uri_mapping.e diff --git a/library/server/wsf/router/uri/wsf_uri_response_handler.e b/library/server/wsf/router/mapping/uri/wsf_uri_response_handler.e similarity index 100% rename from library/server/wsf/router/uri/wsf_uri_response_handler.e rename to library/server/wsf/router/mapping/uri/wsf_uri_response_handler.e diff --git a/library/server/wsf/router/mapping/uri/wsf_uri_routed_service.e b/library/server/wsf/router/mapping/uri/wsf_uri_routed_service.e new file mode 100644 index 00000000..ccb2fdaa --- /dev/null +++ b/library/server/wsf/router/mapping/uri/wsf_uri_routed_service.e @@ -0,0 +1,47 @@ +note + description: "Summary description for {WSF_URI_ROUTED_SERVICE}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_URI_ROUTED_SERVICE + +inherit + WSF_ROUTED_SERVICE + +feature -- Mapping helper: uri + + map_uri (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER) + do + map_uri_with_request_methods (a_uri, h, Void) + end + + map_uri_with_request_methods (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER; rqst_methods: detachable WSF_ROUTER_METHODS) + do + router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, h), rqst_methods) + end + +feature -- Mapping helper: uri agent + + map_uri_agent (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]) + do + map_uri_agent_with_request_methods (a_uri, proc, Void) + end + + map_uri_agent_with_request_methods (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_ROUTER_METHODS) + do + map_uri_with_request_methods (a_uri, create {WSF_AGENT_URI_HANDLER}.make (proc), rqst_methods) + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/router/uri/wsf_uri_template_response_handler.e b/library/server/wsf/router/mapping/uri/wsf_uri_template_response_handler.e similarity index 79% rename from library/server/wsf/router/uri/wsf_uri_template_response_handler.e rename to library/server/wsf/router/mapping/uri/wsf_uri_template_response_handler.e index fa8493c0..5a671204 100644 --- a/library/server/wsf/router/uri/wsf_uri_template_response_handler.e +++ b/library/server/wsf/router/mapping/uri/wsf_uri_template_response_handler.e @@ -12,7 +12,7 @@ inherit feature -- Response - response (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST): WSF_RESPONSE_MESSAGE + response (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE require is_valid_context: is_valid_context (req) deferred @@ -22,10 +22,10 @@ feature -- Response feature -- Execution - execute (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) + execute (req: WSF_REQUEST; res: WSF_RESPONSE) -- Execute request handler do - res.send (response (ctx, req)) + res.send (response (req)) end note diff --git a/library/server/wsf/router/uri_template/wsf_agent_uri_template_handler.e b/library/server/wsf/router/mapping/uri_template/wsf_agent_uri_template_handler.e similarity index 75% rename from library/server/wsf/router/uri_template/wsf_agent_uri_template_handler.e rename to library/server/wsf/router/mapping/uri_template/wsf_agent_uri_template_handler.e index 99950925..e41e546a 100644 --- a/library/server/wsf/router/uri_template/wsf_agent_uri_template_handler.e +++ b/library/server/wsf/router/mapping/uri_template/wsf_agent_uri_template_handler.e @@ -20,13 +20,13 @@ feature {NONE} -- Initialization action := a_action end - action: PROCEDURE [ANY, TUPLE [context: WSF_URI_TEMPLATE_HANDLER_CONTEXT; request: WSF_REQUEST; response: WSF_RESPONSE]] + action: PROCEDURE [ANY, TUPLE [request: WSF_REQUEST; response: WSF_RESPONSE]] feature -- Execution - execute (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) + execute (req: WSF_REQUEST; res: WSF_RESPONSE) do - action.call ([ctx, req, res]) + action.call ([req, res]) end note diff --git a/library/server/wsf/router/mapping/uri_template/wsf_uri_template_handler.e b/library/server/wsf/router/mapping/uri_template/wsf_uri_template_handler.e new file mode 100644 index 00000000..620a0c74 --- /dev/null +++ b/library/server/wsf/router/mapping/uri_template/wsf_uri_template_handler.e @@ -0,0 +1,36 @@ +note + description: "Summary description for EWF_URI_TEMPLATE_HANDLER." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_URI_TEMPLATE_HANDLER + +inherit + WSF_HANDLER + +feature -- Execution + + execute (req: WSF_REQUEST; res: WSF_RESPONSE) + deferred + end + +feature {WSF_ROUTER} -- Mapping + + new_mapping (a_tpl: READABLE_STRING_8): WSF_URI_TEMPLATE_MAPPING + do + create Result.make (a_tpl, Current) + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/router/uri_template/wsf_uri_template_mapping.e b/library/server/wsf/router/mapping/uri_template/wsf_uri_template_mapping.e similarity index 80% rename from library/server/wsf/router/uri_template/wsf_uri_template_mapping.e rename to library/server/wsf/router/mapping/uri_template/wsf_uri_template_mapping.e index af8b7bf3..c76484da 100644 --- a/library/server/wsf/router/uri_template/wsf_uri_template_mapping.e +++ b/library/server/wsf/router/mapping/uri_template/wsf_uri_template_mapping.e @@ -12,16 +12,16 @@ inherit create make, - make_from_string + make_from_template feature {NONE} -- Initialization - make_from_string (s: READABLE_STRING_8; h: like handler) + make (s: READABLE_STRING_8; h: like handler) do - make (create {URI_TEMPLATE}.make (s), h) + make_from_template (create {URI_TEMPLATE}.make (s), h) end - make (tpl: URI_TEMPLATE; h: like handler) + make_from_template (tpl: URI_TEMPLATE; h: like handler) do template := tpl handler := h @@ -46,26 +46,26 @@ feature -- Status local tpl: URI_TEMPLATE p: READABLE_STRING_32 - ctx: detachable WSF_URI_TEMPLATE_HANDLER_CONTEXT + new_src: detachable WSF_REQUEST_PATH_PARAMETERS_PROVIDER do p := path_from_request (req) tpl := based_uri_template (template, a_router) if attached tpl.match (p) as tpl_res then Result := handler - create ctx.make (req, tpl, tpl_res, path_from_request (req)) a_router.execute_before (Current) --| Applied the context to the request --| in practice, this will fill the {WSF_REQUEST}.path_parameters - ctx.apply (req) - handler.execute (ctx, req, res) + create new_src.make (tpl_res.path_variables.count, tpl_res.path_variables) + new_src.apply (req) + handler.execute (req, res) --| Revert {WSF_REQUEST}.path_parameters_source to former value --| In case the request object passed by other handler that alters its values. - ctx.revert (req) + new_src.revert (req) a_router.execute_after (Current) end rescue - if ctx /= Void then - ctx.revert (req) + if new_src /= Void then + new_src.revert (req) end end diff --git a/library/server/wsf/router/mapping/uri_template/wsf_uri_template_routed_service.e b/library/server/wsf/router/mapping/uri_template/wsf_uri_template_routed_service.e new file mode 100644 index 00000000..5b607a9f --- /dev/null +++ b/library/server/wsf/router/mapping/uri_template/wsf_uri_template_routed_service.e @@ -0,0 +1,47 @@ +note + description: "Summary description for {WSF_URI_TEMPLATE_ROUTED_SERVICE}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_URI_TEMPLATE_ROUTED_SERVICE + +inherit + WSF_ROUTED_SERVICE + +feature -- Mapping helper: uri + + map_uri_template (a_tpl: STRING; h: WSF_URI_TEMPLATE_HANDLER) + do + map_uri_template_with_request_methods (a_tpl, h, Void) + end + + map_uri_template_with_request_methods (a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_HANDLER; rqst_methods: detachable WSF_ROUTER_METHODS) + do + router.map_with_request_methods (create {WSF_URI_TEMPLATE_MAPPING}.make (a_tpl, h), rqst_methods) + end + +feature -- Mapping helper: uri agent + + map_uri_template_agent (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]) + do + map_uri_template_agent_with_request_methods (a_tpl, proc, Void) + end + + map_uri_template_agent_with_request_methods (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_ROUTER_METHODS) + do + map_uri_template_with_request_methods (a_tpl, create {WSF_AGENT_URI_TEMPLATE_HANDLER}.make (proc), rqst_methods) + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/draft/library/server/request/rest/src/uri/rest_request_uri_handler_context.e b/library/server/wsf/router/mapping/uri_template/wsf_uri_template_routing_handler.e similarity index 59% rename from draft/library/server/request/rest/src/uri/rest_request_uri_handler_context.e rename to library/server/wsf/router/mapping/uri_template/wsf_uri_template_routing_handler.e index c70a132a..ba2199cc 100644 --- a/draft/library/server/request/rest/src/uri/rest_request_uri_handler_context.e +++ b/library/server/wsf/router/mapping/uri_template/wsf_uri_template_routing_handler.e @@ -1,22 +1,23 @@ note - description: "Summary description for {WSF_URI_HANDLER_CONTEXT}." + description: "Summary description for {WSF_URI_TEMPLATE_ROUTING_HANDLER}." author: "" date: "$Date$" revision: "$Revision$" class - REST_REQUEST_URI_HANDLER_CONTEXT + WSF_URI_TEMPLATE_ROUTING_HANDLER inherit - WSF_URI_HANDLER_CONTEXT + WSF_ROUTING_HANDLER - REST_REQUEST_HANDLER_CONTEXT + WSF_URI_TEMPLATE_HANDLER create - make + make, + make_with_router note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/router/mapping/uri_template_with_context/wsf_agent_uri_template_with_context_handler.e b/library/server/wsf/router/mapping/uri_template_with_context/wsf_agent_uri_template_with_context_handler.e new file mode 100644 index 00000000..b7051f80 --- /dev/null +++ b/library/server/wsf/router/mapping/uri_template_with_context/wsf_agent_uri_template_with_context_handler.e @@ -0,0 +1,42 @@ +note + description: "Summary description for {WSF_AGENT_URI_TEMPLATE_WITH_CONTEXT_HANDLER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_AGENT_URI_TEMPLATE_WITH_CONTEXT_HANDLER + +inherit + WSF_URI_TEMPLATE_WITH_CONTEXT_HANDLER + +create + make + +feature {NONE} -- Initialization + + make (a_action: like action) + do + action := a_action + end + + action: PROCEDURE [ANY, TUPLE [context: WSF_URI_TEMPLATE_HANDLER_CONTEXT; request: WSF_REQUEST; response: WSF_RESPONSE]] + +feature -- Execution + + execute (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) + do + action.call ([ctx, req, res]) + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_handler.e b/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_handler.e new file mode 100644 index 00000000..1f1fde78 --- /dev/null +++ b/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_handler.e @@ -0,0 +1,36 @@ +note + description: "Summary description for EWF_URI_TEMPLATE_WITH_CONTEXT_HANDLER." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_URI_TEMPLATE_WITH_CONTEXT_HANDLER + +inherit + WSF_HANDLER + +feature -- Execution + + execute (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) + deferred + end + +feature {WSF_ROUTER} -- Mapping + + new_mapping (a_tpl: READABLE_STRING_8): WSF_URI_TEMPLATE_WITH_CONTEXT_MAPPING + do + create Result.make (a_tpl, Current) + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/router/uri_template/wsf_uri_template_handler_context.e b/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_handler_context.e similarity index 100% rename from library/server/wsf/router/uri_template/wsf_uri_template_handler_context.e rename to library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_handler_context.e diff --git a/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_mapping.e b/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_mapping.e new file mode 100644 index 00000000..e4c34090 --- /dev/null +++ b/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_mapping.e @@ -0,0 +1,95 @@ +note + description: "Summary description for {EWF_ROUTER_URI_TEMPLATE_WITH_CONTEXT_PATH}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_URI_TEMPLATE_WITH_CONTEXT_MAPPING + +inherit + WSF_ROUTER_MAPPING + +create + make, + make_from_template + +feature {NONE} -- Initialization + + make (s: READABLE_STRING_8; h: like handler) + do + make_from_template (create {URI_TEMPLATE}.make (s), h) + end + + make_from_template (tpl: URI_TEMPLATE; h: like handler) + do + template := tpl + handler := h + end + +feature -- Access + + handler: WSF_URI_TEMPLATE_WITH_CONTEXT_HANDLER + + template: URI_TEMPLATE + +feature -- Element change + + set_handler (h: like handler) + do + handler := h + end + +feature -- Status + + routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER + local + tpl: URI_TEMPLATE + p: READABLE_STRING_32 + ctx: detachable WSF_URI_TEMPLATE_HANDLER_CONTEXT + do + p := path_from_request (req) + tpl := based_uri_template (template, a_router) + if attached tpl.match (p) as tpl_res then + Result := handler + create ctx.make (req, tpl, tpl_res, path_from_request (req)) + a_router.execute_before (Current) + --| Applied the context to the request + --| in practice, this will fill the {WSF_REQUEST}.path_parameters + ctx.apply (req) + handler.execute (ctx, req, res) + --| Revert {WSF_REQUEST}.path_parameters_source to former value + --| In case the request object passed by other handler that alters its values. + ctx.revert (req) + a_router.execute_after (Current) + end + rescue + if ctx /= Void then + ctx.revert (req) + end + end + +feature {NONE} -- Implementation + + based_uri_template (a_tpl: like template; a_router: WSF_ROUTER): like template + do + if attached a_router.base_url as l_base_url then + Result := a_tpl.duplicate + Result.set_template (l_base_url + a_tpl.template) + else + Result := a_tpl + end + end + + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_routed_service.e b/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_routed_service.e new file mode 100644 index 00000000..8b92556a --- /dev/null +++ b/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_routed_service.e @@ -0,0 +1,47 @@ +note + description: "Summary description for {WSF_URI_TEMPLATE_WITH_CONTEXT_ROUTED_SERVICE}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_URI_TEMPLATE_WITH_CONTEXT_ROUTED_SERVICE + +inherit + WSF_ROUTED_SERVICE + +feature -- Mapping helper: uri + + map_uri_template (a_tpl: STRING; h: WSF_URI_TEMPLATE_WITH_CONTEXT_HANDLER) + do + map_uri_template_with_request_methods (a_tpl, h, Void) + end + + map_uri_template_with_request_methods (a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_WITH_CONTEXT_HANDLER; rqst_methods: detachable WSF_ROUTER_METHODS) + do + router.map_with_request_methods (create {WSF_URI_TEMPLATE_WITH_CONTEXT_MAPPING}.make (a_tpl, h), rqst_methods) + end + +feature -- Mapping helper: uri agent + + map_uri_template_agent (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE]]) + do + map_uri_template_agent_with_request_methods (a_tpl, proc, Void) + end + + map_uri_template_agent_with_request_methods (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_ROUTER_METHODS) + do + map_uri_template_with_request_methods (a_tpl, create {WSF_AGENT_URI_TEMPLATE_WITH_CONTEXT_HANDLER}.make (proc), rqst_methods) + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_routing_handler.e b/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_routing_handler.e new file mode 100644 index 00000000..09db9834 --- /dev/null +++ b/library/server/wsf/router/mapping/uri_template_with_context/wsf_uri_template_with_context_routing_handler.e @@ -0,0 +1,39 @@ +note + description: "Summary description for {WSF_URI_TEMPLATE_WITH_CONTEXT_ROUTING_HANDLER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_URI_TEMPLATE_WITH_CONTEXT_ROUTING_HANDLER + +inherit + WSF_ROUTING_HANDLER + + WSF_URI_TEMPLATE_WITH_CONTEXT_HANDLER + rename + execute as uri_template_xecute + end + +create + make, + make_with_router + +feature -- Execution + + uri_template_xecute (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) + do + execute (req, res) + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/router/starts_with/wsf_starts_with_handler.e b/library/server/wsf/router/starts_with/wsf_starts_with_handler.e deleted file mode 100644 index 19c3a037..00000000 --- a/library/server/wsf/router/starts_with/wsf_starts_with_handler.e +++ /dev/null @@ -1,19 +0,0 @@ -note - description: "Summary description for {WSF_STARTS_WITH_HANDLER}." - author: "" - date: "$Date$" - revision: "$Revision$" - -deferred class - WSF_STARTS_WITH_HANDLER - -inherit - WSF_HANDLER - -feature -- Execution - - execute (a_start_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE) - deferred - end - -end diff --git a/library/server/wsf/router/uri/wsf_uri_handler.e b/library/server/wsf/router/uri/wsf_uri_handler.e deleted file mode 100644 index 74e63523..00000000 --- a/library/server/wsf/router/uri/wsf_uri_handler.e +++ /dev/null @@ -1,19 +0,0 @@ -note - description: "Summary description for {EWF_ROUTER_URI_PATH_HANDLER}." - author: "" - date: "$Date$" - revision: "$Revision$" - -deferred class - WSF_URI_HANDLER - -inherit - WSF_HANDLER - -feature -- Execution - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - deferred - end - -end diff --git a/library/server/wsf/router/uri_template/wsf_uri_template_handler.e b/library/server/wsf/router/uri_template/wsf_uri_template_handler.e deleted file mode 100644 index 3f5d8f96..00000000 --- a/library/server/wsf/router/uri_template/wsf_uri_template_handler.e +++ /dev/null @@ -1,19 +0,0 @@ -note - description: "Summary description for EWF_URI_TEMPLATE_HANDLER." - author: "" - date: "$Date$" - revision: "$Revision$" - -deferred class - WSF_URI_TEMPLATE_HANDLER - -inherit - WSF_HANDLER - -feature -- Execution - - execute (ctx: WSF_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) - deferred - end - -end diff --git a/library/server/wsf/router/wsf_file_system_handler.e b/library/server/wsf/router/wsf_file_system_handler.e index 01626c60..c1500d86 100644 --- a/library/server/wsf/router/wsf_file_system_handler.e +++ b/library/server/wsf/router/wsf_file_system_handler.e @@ -20,7 +20,7 @@ feature {NONE} -- Initialization make (d: like document_root) require - valid_d: (d /= Void and then not d.is_empty) implies d.ends_with ("/") + valid_d: (d /= Void and then not d.is_empty) implies not d.ends_with (operating_environment.directory_separator.out) local e: EXECUTION_ENVIRONMENT do @@ -30,6 +30,8 @@ feature {NONE} -- Initialization else document_root := d end + ensure + not document_root.is_empty and then not document_root.ends_with (operating_environment.directory_separator.out) end feature -- Access @@ -337,7 +339,7 @@ feature {NONE} -- Implementation resource_filename (uri: READABLE_STRING_8): READABLE_STRING_8 do - Result := real_filename (document_root + real_filename (uri)) + Result := real_filename (document_root + operating_environment.directory_separator.out + real_filename (uri)) end dirname (uri: READABLE_STRING_8): READABLE_STRING_8 @@ -450,4 +452,14 @@ feature {NONE} -- implementation: date time Result := date_time_utility.unix_time_stamp_to_date_time (n) end +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/router/wsf_handler.e b/library/server/wsf/router/wsf_handler.e index 17d8d161..e39c89d1 100644 --- a/library/server/wsf/router/wsf_handler.e +++ b/library/server/wsf/router/wsf_handler.e @@ -14,8 +14,15 @@ feature -- Status report do Result := True end - -feature {WSF_ROUTER} -- Mapping change + +feature {WSF_ROUTER} -- Mapping + + new_mapping (a_resource: READABLE_STRING_8): WSF_ROUTER_MAPPING + -- New mapping built with Current as handler + deferred + ensure + Result /= Void and then Result.handler = Current + end on_mapped (a_mapping: WSF_ROUTER_MAPPING; a_rqst_methods: detachable WSF_ROUTER_METHODS) -- Callback called when a router map a route to Current handler diff --git a/library/server/wsf/router/wsf_router.e b/library/server/wsf/router/wsf_router.e index ed039aed..99cbd191 100644 --- a/library/server/wsf/router/wsf_router.e +++ b/library/server/wsf/router/wsf_router.e @@ -57,6 +57,21 @@ feature -- Mapping a_mapping.handler.on_mapped (a_mapping, rqst_methods) end +feature -- Mapping handler + + handle (a_resource: READABLE_STRING_8; h: WSF_HANDLER) + -- Map the mapping associated to handler `h' for resource `a_resource' + do + handle_with_request_methods (a_resource, h, Void) + end + + handle_with_request_methods (a_resource: READABLE_STRING_8; h: WSF_HANDLER; rqst_methods: detachable WSF_ROUTER_METHODS) + -- Map the mapping associated to handler `h' for resource `a_resource' + -- and only for request methods `rqst_methods' + do + map_with_request_methods (h.new_mapping (a_resource), rqst_methods) + end + feature -- Access is_dispatched: BOOLEAN diff --git a/library/server/wsf/router/wsf_router_mapping.e b/library/server/wsf/router/wsf_router_mapping.e index f5fb7491..a04b5cdb 100644 --- a/library/server/wsf/router/wsf_router_mapping.e +++ b/library/server/wsf/router/wsf_router_mapping.e @@ -7,6 +7,12 @@ note deferred class WSF_ROUTER_MAPPING +feature {NONE} -- Initialization + + make (a_resource: READABLE_STRING_8; h: like handler) + deferred + end + feature -- Access handler: WSF_HANDLER diff --git a/library/server/wsf/router/wsf_router_methods.e b/library/server/wsf/router/wsf_router_methods.e index 8d975789..efbad2b2 100644 --- a/library/server/wsf/router/wsf_router_methods.e +++ b/library/server/wsf/router/wsf_router_methods.e @@ -62,11 +62,7 @@ feature {NONE} -- Initialization make_from_iterable (v: ITERABLE [READABLE_STRING_8]) do make (1) - across - v as vc - loop - add_method_using_constant (vc.item) - end + add_methods (v) end make_from_string (v: READABLE_STRING_8) @@ -115,6 +111,19 @@ feature -- Status change is_locked := True end +feature -- Basic operations + + add alias "+" (a_other: WSF_ROUTER_METHODS): WSF_ROUTER_METHODS + -- Merge Current and a_other into Result + require + a_other_not_void: a_other /= Void + do + create Result.make_from_iterable (Current) + Result.add_methods (a_other) + ensure + + end + feature -- Element change enable_get @@ -328,7 +337,21 @@ feature -- Access Result := methods.to_array end -feature {NONE} -- Implementation +feature {WSF_ROUTER_METHODS} -- Implementation + + add_methods (lst: ITERABLE [READABLE_STRING_8]) + -- Enable methods from `lst' + do + if not is_locked then + across + lst as c + loop + add_method_using_constant (c.item) + end + end + end + +feature {NONE} -- Implementation add_method_using_constant (v: READABLE_STRING_8) -- Add method `v' using method_* constant @@ -358,15 +381,6 @@ feature {NONE} -- Implementation method_set: has (v.as_upper) end - add_method (v: READABLE_STRING_8) - require - is_upper_case: v.same_string (v.as_upper) - do - if not is_locked then - methods.extend (v) - end - end - prune_method (v: READABLE_STRING_8) require is_upper_case: v.same_string (v.as_upper) diff --git a/library/server/wsf/router/wsf_routing_handler.e b/library/server/wsf/router/wsf_routing_handler.e new file mode 100644 index 00000000..917ac167 --- /dev/null +++ b/library/server/wsf/router/wsf_routing_handler.e @@ -0,0 +1,75 @@ +note + description: "Summary description for {WSF_ROUTING_HANDLER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_ROUTING_HANDLER + +inherit + WSF_HANDLER + +feature {NONE} -- Initialization + + make_with_router (a_router: like router) + do + router := a_router + end + + make (n: INTEGER) + do + make_with_router (create {WSF_ROUTER}.make (n)) + end + +feature -- Access + + router: WSF_ROUTER + +feature -- Access + + count: INTEGER + -- Count of maps handled by current + do + Result := router.count + end + + base_url: detachable READABLE_STRING_8 + do + Result := router.base_url + end + +feature -- Element change + + set_base_url (a_base_url: like base_url) + -- Set `base_url' to `a_base_url' + -- make sure no map is already added (i.e: count = 0) + require + no_handler_set: count = 0 + do + router.set_base_url (a_base_url) + end + +feature -- Execution + + execute (req: WSF_REQUEST; res: WSF_RESPONSE) + -- Execute request handler + do + if attached router.dispatch_and_return_handler (req, res) as h then + check is_dispatched: router.is_dispatched end + else + res.put_header ({HTTP_STATUS_CODE}.not_found, <<[{HTTP_HEADER_NAMES}.header_content_length, "0"]>>) + end + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/src/filter/wsf_filter_handler.e b/library/server/wsf/src/filter/wsf_filter_handler.e index f06f0082..0ea0669d 100644 --- a/library/server/wsf/src/filter/wsf_filter_handler.e +++ b/library/server/wsf/src/filter/wsf_filter_handler.e @@ -8,19 +8,19 @@ note revision: "$Revision$" deferred class - WSF_FILTER_HANDLER [C -> WSF_HANDLER_CONTEXT] + WSF_FILTER_HANDLER [H -> WSF_HANDLER] inherit - WSF_HANDLER [C] + WSF_HANDLER feature -- Access - next: detachable WSF_FILTER_HANDLER [C] - -- Next filter + next: detachable H + -- Next handler feature -- Element change - set_next (a_next: WSF_FILTER_HANDLER [C]) + set_next (a_next: like next) -- Set `next' to `a_next' do next := a_next @@ -28,16 +28,6 @@ feature -- Element change next_set: next = a_next end -feature {NONE} -- Implementation - - execute_next (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) - -- Execute the `next' filter. - do - if attached next as n then - n.execute (ctx, req, res) - end - end - note copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/library/server/wsf/src/filter/wsf_filter_uri_handler.e b/library/server/wsf/src/filter/wsf_filter_uri_handler.e new file mode 100644 index 00000000..19d4e87a --- /dev/null +++ b/library/server/wsf/src/filter/wsf_filter_uri_handler.e @@ -0,0 +1,34 @@ +note + description : "Objects that ..." + author : "$Author$" + date : "$Date$" + revision : "$Revision$" + +deferred class + WSF_FILTER_URI_HANDLER + +inherit + WSF_FILTER_HANDLER [WSF_URI_HANDLER] + + WSF_URI_HANDLER + +feature -- Execution + + execute_next (req: WSF_REQUEST; res: WSF_RESPONSE) + do + if attached next as n then + n.execute (req, res) + end + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/src/filter/wsf_filter_uri_template_handler.e b/library/server/wsf/src/filter/wsf_filter_uri_template_handler.e new file mode 100644 index 00000000..296d4fde --- /dev/null +++ b/library/server/wsf/src/filter/wsf_filter_uri_template_handler.e @@ -0,0 +1,34 @@ +note + description : "Objects that ..." + author : "$Author$" + date : "$Date$" + revision : "$Revision$" + +deferred class + WSF_FILTER_URI_TEMPLATE_HANDLER + +inherit + WSF_FILTER_HANDLER [WSF_URI_TEMPLATE_HANDLER] + + WSF_URI_TEMPLATE_HANDLER + +feature -- Execution + + execute_next (req: WSF_REQUEST; res: WSF_RESPONSE) + do + if attached next as n then + n.execute (req, res) + end + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/src/filter/wsf_uri_template_filtered_service.e b/library/server/wsf/src/filter/wsf_filtered_service.e similarity index 88% rename from library/server/wsf/src/filter/wsf_uri_template_filtered_service.e rename to library/server/wsf/src/filter/wsf_filtered_service.e index cc8a859b..781c59c1 100644 --- a/library/server/wsf/src/filter/wsf_uri_template_filtered_service.e +++ b/library/server/wsf/src/filter/wsf_filtered_service.e @@ -1,11 +1,11 @@ note - description: "Summary description for {WSF_URI_TEMPLATE_FILTERED_SERVICE}." + description: "Summary description for {WSF_FILTERED_SERVICE}." author: "" date: "$Date$" revision: "$Revision$" deferred class - WSF_URI_TEMPLATE_FILTERED_SERVICE + WSF_FILTERED_SERVICE feature {NONE} -- Initialization diff --git a/library/server/wsf/src/filter/wsf_routing_filter.e b/library/server/wsf/src/filter/wsf_routing_filter.e deleted file mode 100644 index 9b42cbf7..00000000 --- a/library/server/wsf/src/filter/wsf_routing_filter.e +++ /dev/null @@ -1,75 +0,0 @@ -note - description: "Routing filter." - author: "Olivier Ligot" - date: "$Date$" - revision: "$Revision$" - -class - WSF_ROUTING_FILTER [H -> WSF_HANDLER [C], C -> WSF_HANDLER_CONTEXT] - -inherit - WSF_FILTER - -create - make - -feature {NONE} -- Initialization - - make (a_router: WSF_ROUTER [H, C]) - do - router := a_router - ensure - router_set: router = a_router - end - -feature -- Access - - router: WSF_ROUTER [H, C] - -- Router - - execute_default_action: detachable PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]] - -- `execute_default' action - -feature -- Element change - - set_execute_default_action (an_action: like execute_default_action) - -- Set `execute_default_action' to `an_action' - do - execute_default_action := an_action - ensure - execute_default_action_set: execute_default_action = an_action - end - -feature -- Basic operations - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - -- Execute the filter - do - if attached router.route (req) as r then - router.execute_route (r, req, res) - else - execute_default (req, res) - end - execute_next (req, res) - end - - execute_default (req: WSF_REQUEST; res: WSF_RESPONSE) - do - if attached execute_default_action as action then - action.call ([req, res]) - else - do_nothing - end - end - -note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf/src/wsf_request_path_parameters_provider.e b/library/server/wsf/src/wsf_request_path_parameters_provider.e new file mode 100644 index 00000000..59f60860 --- /dev/null +++ b/library/server/wsf/src/wsf_request_path_parameters_provider.e @@ -0,0 +1,59 @@ +note + description: "Summary description for {WSF_REQUEST_PATH_PARAMETERS_PROVIDER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_REQUEST_PATH_PARAMETERS_PROVIDER + +inherit + WSF_REQUEST_PATH_PARAMETERS_SOURCE + +create + make + +feature {NONE} -- Initialization + + make (nb: INTEGER; a_urlencoded_path_parameters: like urlencoded_path_parameters) + do + path_parameters_count := nb + urlencoded_path_parameters := a_urlencoded_path_parameters + end + +feature -- Access + + path_parameters_count: INTEGER + + urlencoded_path_parameters: TABLE_ITERABLE [READABLE_STRING_8, READABLE_STRING_8] + -- Raw urlencoded path parameters. + +feature -- Operation + + previous_path_parameters_source: detachable WSF_REQUEST_PATH_PARAMETERS_SOURCE + + apply (req: WSF_REQUEST) + -- + do + previous_path_parameters_source := req.path_parameters_source + req.set_path_parameters_source (Current) + end + + revert (req: WSF_REQUEST) + -- + do + req.set_path_parameters_source (previous_path_parameters_source) + previous_path_parameters_source := Void + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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 diff --git a/library/server/wsf_extension/src/wsf_resource_handler_helper.e b/library/server/wsf_extension/src/wsf_resource_handler_helper.e index 041cd9c5..eef2ba1e 100644 --- a/library/server/wsf_extension/src/wsf_resource_handler_helper.e +++ b/library/server/wsf_extension/src/wsf_resource_handler_helper.e @@ -5,160 +5,160 @@ note revision: "$Revision$" class - WSF_RESOURCE_HANDLER_HELPER [C -> WSF_HANDLER_CONTEXT] + WSF_RESOURCE_HANDLER_HELPER feature -- Execute template - execute_methods (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_methods (req: WSF_REQUEST; res: WSF_RESPONSE) -- Execute request and dispatch according to the request method local m: READABLE_STRING_8 do m := req.request_method.as_upper if m.same_string ({HTTP_REQUEST_METHODS}.method_get) then - execute_get (ctx, req, res) + execute_get (req, res) elseif m.same_string ({HTTP_REQUEST_METHODS}.method_put) then - execute_put (ctx, req, res) + execute_put (req, res) elseif m.same_string ({HTTP_REQUEST_METHODS}.method_delete) then - execute_delete (ctx, req, res) + execute_delete (req, res) elseif m.same_string ({HTTP_REQUEST_METHODS}.method_post) then - execute_post (ctx, req, res) + execute_post (req, res) elseif m.same_string ({HTTP_REQUEST_METHODS}.method_trace) then - execute_trace (ctx, req, res) + execute_trace (req, res) elseif m.same_string ({HTTP_REQUEST_METHODS}.method_options) then - execute_options (ctx, req, res) + execute_options (req, res) elseif m.same_string ({HTTP_REQUEST_METHODS}.method_head) then - execute_head (ctx, req, res) + execute_head (req, res) elseif m.same_string ({HTTP_REQUEST_METHODS}.method_connect) then - execute_connect (ctx, req, res) + execute_connect (req, res) else --| Eventually handle other methods... - execute_extension_method (ctx, req, res) + execute_extension_method (req, res) end end feature -- Method Post - execute_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_post (req: WSF_REQUEST; res: WSF_RESPONSE) do if req.is_chunked_input then - do_post (ctx, req, res) + do_post (req, res) else if req.content_length_value > 0 then - do_post (ctx, req, res) + do_post (req, res) else - handle_bad_request_response ("Bad request, content_length empty", ctx, req, res) + handle_bad_request_response ("Bad request, content_length empty", req, res) end end end - do_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + do_post (req: WSF_REQUEST; res: WSF_RESPONSE) do - handle_not_implemented ("Method POST not implemented", ctx, req, res) + handle_not_implemented ("Method POST not implemented", req, res) end feature-- Method Put - execute_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_put (req: WSF_REQUEST; res: WSF_RESPONSE) do if req.is_chunked_input then - do_put (ctx, req, res) + do_put (req, res) else if req.content_length_value > 0 then - do_put (ctx, req, res) + do_put (req, res) else - handle_bad_request_response ("Bad request, content_length empty", ctx, req, res) + handle_bad_request_response ("Bad request, content_length empty", req, res) end end end - do_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + do_put (req: WSF_REQUEST; res: WSF_RESPONSE) do - handle_not_implemented ("Method PUT not implemented", ctx, req, res) + handle_not_implemented ("Method PUT not implemented", req, res) end feature -- Method Get - execute_get (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_get (req: WSF_REQUEST; res: WSF_RESPONSE) do - do_get (ctx, req, res) + do_get (req, res) end - do_get (ctx: C;req: WSF_REQUEST; res: WSF_RESPONSE) + do_get (req: WSF_REQUEST; res: WSF_RESPONSE) do - handle_not_implemented ("Method GET not implemented", ctx, req, res) + handle_not_implemented ("Method GET not implemented", req, res) end feature -- Method DELETE - execute_delete (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_delete (req: WSF_REQUEST; res: WSF_RESPONSE) do - do_delete (ctx, req, res) + do_delete (req, res) end - do_delete (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + do_delete (req: WSF_REQUEST; res: WSF_RESPONSE) do - handle_not_implemented ("Method DELETE not implemented", ctx, req, res) + handle_not_implemented ("Method DELETE not implemented", req, res) end feature -- Method CONNECT - execute_connect (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_connect (req: WSF_REQUEST; res: WSF_RESPONSE) do - do_connect (ctx, req, res) + do_connect (req, res) end - do_connect (ctx: C;req: WSF_REQUEST; res: WSF_RESPONSE) + do_connect (req: WSF_REQUEST; res: WSF_RESPONSE) do - handle_not_implemented ("Method CONNECT not implemented", ctx, req, res) + handle_not_implemented ("Method CONNECT not implemented", req, res) end feature -- Method HEAD - execute_head (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_head (req: WSF_REQUEST; res: WSF_RESPONSE) do - do_head (ctx, req, res) + do_head (req, res) end - do_head (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + do_head (req: WSF_REQUEST; res: WSF_RESPONSE) do - handle_not_implemented ("Method HEAD not implemented", ctx, req, res) + handle_not_implemented ("Method HEAD not implemented", req, res) end feature -- Method OPTIONS - execute_options (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_options (req: WSF_REQUEST; res: WSF_RESPONSE) do - do_options (ctx, req, res) + do_options (req, res) end - do_options (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + do_options (req: WSF_REQUEST; res: WSF_RESPONSE) do - handle_not_implemented ("Method OPTIONS not implemented", ctx, req, res) + handle_not_implemented ("Method OPTIONS not implemented", req, res) end feature -- Method TRACE - execute_trace (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_trace (req: WSF_REQUEST; res: WSF_RESPONSE) do - do_trace (ctx, req, res) + do_trace (req, res) end - do_trace (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + do_trace (req: WSF_REQUEST; res: WSF_RESPONSE) do - handle_not_implemented ("Method TRACE not implemented", ctx, req, res) + handle_not_implemented ("Method TRACE not implemented", req, res) end feature -- Method Extension Method - execute_extension_method (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + execute_extension_method (req: WSF_REQUEST; res: WSF_RESPONSE) do - do_extension_method (ctx, req, res) + do_extension_method (req, res) end - do_extension_method (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + do_extension_method (req: WSF_REQUEST; res: WSF_RESPONSE) do - handle_not_implemented ("Method extension-method not implemented", ctx, req, res) + handle_not_implemented ("Method extension-method not implemented", req, res) end feature -- Retrieve content from WGI_INPUT_STREAM @@ -208,7 +208,7 @@ feature -- Handle responses Result := Void end - handle_bad_request_response (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE ) + handle_bad_request_response (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE ) local h : HTTP_HEADER do @@ -221,7 +221,7 @@ feature -- Handle responses res.put_string (a_description) end - handle_precondition_fail_response (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE ) + handle_precondition_fail_response (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE ) local h : HTTP_HEADER do @@ -234,7 +234,7 @@ feature -- Handle responses res.put_string (a_description) end - handle_internal_server_error (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE ) + handle_internal_server_error (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE ) local h : HTTP_HEADER do @@ -247,7 +247,7 @@ feature -- Handle responses res.put_string (a_description) end - handle_not_implemented (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE ) + handle_not_implemented (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE ) local h : HTTP_HEADER do @@ -260,7 +260,7 @@ feature -- Handle responses res.put_string (a_description) end - handle_method_not_allowed_response (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + handle_method_not_allowed_response (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE) local h : HTTP_HEADER do @@ -273,7 +273,7 @@ feature -- Handle responses res.put_string (a_description) end - handle_resource_not_found_response (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + handle_resource_not_found_response (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE) local h : HTTP_HEADER do @@ -287,7 +287,7 @@ feature -- Handle responses end - handle_resource_not_modified_response (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + handle_resource_not_modified_response (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE) local h : HTTP_HEADER do @@ -302,7 +302,7 @@ feature -- Handle responses end - handle_resource_conflict_response (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) + handle_resource_conflict_response (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE) local h : HTTP_HEADER do