From 95cebe26bb8f0191a55131bf194590bd821433b4 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 3 Nov 2017 17:59:10 +0100 Subject: [PATCH] Added routing condition mapping. Added WSF_EXECUTE_HANDLER as common ancestor for handler with `execute (WSF_REQUEST, WSF_RESPONSE) ..` routine. Made more flexible a few routine by accepting ITERABLE instead of ARRAY, and READABLE_STRING_GENERAL when possible. --- .../wsf_router_self_documentation_message.e | 28 +++-- .../helpers/wsf_routing_agent_condition.e | 43 +++++++ .../helpers/wsf_routing_extension_condition.e | 44 +++++++ .../wsf_routing_file_exists_condition.e | 39 +++++++ .../wsf_routing_path_exists_condition.e | 64 ++++++++++ .../condition/wsf_routing_and_condition.e | 43 +++++++ .../support/condition/wsf_routing_condition.e | 39 +++++++ .../condition/wsf_routing_or_condition.e | 43 +++++++ .../condition/wsf_with_condition_handler.e | 22 ++++ .../condition/wsf_with_condition_mapping.e | 44 +++++++ .../condition/wsf_with_condition_mapping_i.e | 109 ++++++++++++++++++ .../helpers/wsf_execute_agent_handler.e | 45 ++++++++ .../helpers/wsf_execute_filter_handler.e | 34 ++++++ .../wsf_execute_response_agent_handler.e | 44 +++++++ .../helpers/wsf_execute_response_handler.e | 40 +++++++ .../helpers/wsf_execute_routing_handler.e | 28 +++++ ...sf_self_documented_execute_agent_handler.e | 61 ++++++++++ .../support/execute/wsf_execute_handler.e | 34 ++++++ .../wsf_self_documented_uri_agent_handler.e | 3 +- .../uri/helpers/wsf_uri_agent_handler.e | 21 +--- .../uri/helpers/wsf_uri_filter_handler.e | 13 +-- .../helpers/wsf_uri_response_agent_handler.e | 22 +--- .../uri/helpers/wsf_uri_response_handler.e | 22 +--- .../wsf/router/support/uri/wsf_uri_handler.e | 14 +-- .../helpers/wsf_uri_template_agent_handler.e | 22 +--- .../helpers/wsf_uri_template_filter_handler.e | 13 +-- .../wsf_uri_template_response_agent_handler.e | 22 +--- .../wsf_uri_template_response_handler.e | 22 +--- .../uri_template/wsf_uri_template_handler.e | 14 +-- .../wsf/router/wsf_file_system_handler.e | 4 +- .../server/wsf/router/wsf_router_mapping.e | 10 -- .../server/wsf/router/wsf_routing_handler.e | 2 +- 32 files changed, 822 insertions(+), 186 deletions(-) create mode 100644 library/server/wsf/router/support/condition/helpers/wsf_routing_agent_condition.e create mode 100644 library/server/wsf/router/support/condition/helpers/wsf_routing_extension_condition.e create mode 100644 library/server/wsf/router/support/condition/helpers/wsf_routing_file_exists_condition.e create mode 100644 library/server/wsf/router/support/condition/helpers/wsf_routing_path_exists_condition.e create mode 100644 library/server/wsf/router/support/condition/wsf_routing_and_condition.e create mode 100644 library/server/wsf/router/support/condition/wsf_routing_condition.e create mode 100644 library/server/wsf/router/support/condition/wsf_routing_or_condition.e create mode 100644 library/server/wsf/router/support/condition/wsf_with_condition_handler.e create mode 100644 library/server/wsf/router/support/condition/wsf_with_condition_mapping.e create mode 100644 library/server/wsf/router/support/condition/wsf_with_condition_mapping_i.e create mode 100644 library/server/wsf/router/support/execute/helpers/wsf_execute_agent_handler.e create mode 100644 library/server/wsf/router/support/execute/helpers/wsf_execute_filter_handler.e create mode 100644 library/server/wsf/router/support/execute/helpers/wsf_execute_response_agent_handler.e create mode 100644 library/server/wsf/router/support/execute/helpers/wsf_execute_response_handler.e create mode 100644 library/server/wsf/router/support/execute/helpers/wsf_execute_routing_handler.e create mode 100644 library/server/wsf/router/support/execute/helpers/wsf_self_documented_execute_agent_handler.e create mode 100644 library/server/wsf/router/support/execute/wsf_execute_handler.e diff --git a/library/server/wsf/router/documentation/wsf_router_self_documentation_message.e b/library/server/wsf/router/documentation/wsf_router_self_documentation_message.e index 8ee3882e..99a0118d 100644 --- a/library/server/wsf/router/documentation/wsf_router_self_documentation_message.e +++ b/library/server/wsf/router/documentation/wsf_router_self_documentation_message.e @@ -221,17 +221,19 @@ feature {WSF_RESPONSE} -- Output l_url := Void s.append ("
  • ") - s.append ("") - if doc_url_supported then - s.append ("") - s.append (m.associated_resource) - s.append ("") - else - s.append (m.associated_resource) + if attached m.associated_resource as l_associated_resource then + s.append ("") + if doc_url_supported then + s.append ("") + s.append (l_associated_resource) + s.append ("") + else + s.append (l_associated_resource) + end + s.append ("") end - s.append ("") if meths /= Void then s.append (" [") @@ -291,7 +293,11 @@ feature {WSF_RESPONSE} -- Output s.append ("
  • %N") else debug - s.append ("
  • " + m.associated_resource + " is HIDDEN
  • %N") + if attached m.associated_resource as l_associated_resource then + s.append ("
  • " + l_associated_resource + " is HIDDEN
  • %N") + else + s.append ("
  • HIDDEN
  • %N") + end end end end diff --git a/library/server/wsf/router/support/condition/helpers/wsf_routing_agent_condition.e b/library/server/wsf/router/support/condition/helpers/wsf_routing_agent_condition.e new file mode 100644 index 00000000..d7d74008 --- /dev/null +++ b/library/server/wsf/router/support/condition/helpers/wsf_routing_agent_condition.e @@ -0,0 +1,43 @@ +note + description: "Summary description for {WSF_ROUTING_AGENT_CONDITION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_ROUTING_AGENT_CONDITION + +inherit + WSF_ROUTING_CONDITION + +create + make + +feature {NONE} -- Initialization + + make (act: like condition) + do + condition := act + end + + condition: FUNCTION [TUPLE [request: WSF_REQUEST], BOOLEAN] + +feature -- Status report + + accepted (req: WSF_REQUEST): BOOLEAN + -- Does `req` satisfy Current condition? + do + Result := condition (req) + end + +note + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/condition/helpers/wsf_routing_extension_condition.e b/library/server/wsf/router/support/condition/helpers/wsf_routing_extension_condition.e new file mode 100644 index 00000000..e414af57 --- /dev/null +++ b/library/server/wsf/router/support/condition/helpers/wsf_routing_extension_condition.e @@ -0,0 +1,44 @@ +note + description: "[ + Request path info ends with one of the specified extensions. + ]" + date: "$Date$" + revision: "$Revision$" + +class + WSF_ROUTING_EXTENSION_CONDITION + +inherit + WSF_ROUTING_CONDITION + +create + make + +feature {NONE} -- Creation + + make (a_extension_list: ITERABLE [READABLE_STRING_GENERAL]) + do + extension_list := a_extension_list + end + +feature -- Access + + extension_list: ITERABLE [READABLE_STRING_GENERAL] + +feature -- Status report + + accepted (req: WSF_REQUEST): BOOLEAN + -- Does `req` satisfy Current condition? + local + l_path: READABLE_STRING_GENERAL + i: INTEGER + do + l_path := req.percent_encoded_path_info + i := l_path.last_index_of ('.', l_path.count) + if i > 0 then + i := i + 1 + Result := across extension_list as ic some ic.item.same_caseless_characters (l_path, i, l_path.count, 1) end + end + end + +end diff --git a/library/server/wsf/router/support/condition/helpers/wsf_routing_file_exists_condition.e b/library/server/wsf/router/support/condition/helpers/wsf_routing_file_exists_condition.e new file mode 100644 index 00000000..a85b6b0e --- /dev/null +++ b/library/server/wsf/router/support/condition/helpers/wsf_routing_file_exists_condition.e @@ -0,0 +1,39 @@ +note + description: "[ + Request path info is associated with existing file. + ]" + date: "$Date$" + revision: "$Revision$" + +class + WSF_ROUTING_FILE_EXISTS_CONDITION + +inherit + WSF_ROUTING_PATH_EXISTS_CONDITION + redefine + path_exists + end + +create + make + +feature -- Status report + + path_exists (p: PATH): BOOLEAN + local + fut: FILE_UTILITIES + do + Result := fut.file_path_exists (p) + end + +note + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/condition/helpers/wsf_routing_path_exists_condition.e b/library/server/wsf/router/support/condition/helpers/wsf_routing_path_exists_condition.e new file mode 100644 index 00000000..b3ec0572 --- /dev/null +++ b/library/server/wsf/router/support/condition/helpers/wsf_routing_path_exists_condition.e @@ -0,0 +1,64 @@ +note + description: "[ + Request path info is associated with existing file or folder. + ]" + date: "$Date$" + revision: "$Revision$" + +class + WSF_ROUTING_PATH_EXISTS_CONDITION + +inherit + WSF_ROUTING_CONDITION + +create + make + +feature {NONE} -- Creation + + make (a_parent_location: PATH) + do + parent_location := a_parent_location + end + +feature -- Access + + parent_location: PATH + +feature -- Status report + + path_exists (p: PATH): BOOLEAN + local + fut: FILE_UTILITIES + do + Result := fut.file_path_exists (p) or fut.directory_path_exists (p) + end + + accepted (req: WSF_REQUEST): BOOLEAN + -- Does `req` satisfy Current condition? + local + l_path: READABLE_STRING_GENERAL + p: PATH + fut: FILE_UTILITIES + do + l_path := req.path_info + if not l_path.is_empty then + if l_path[1] = '/' then + l_path := l_path.substring (2, l_path.count) + end + p := parent_location.extended (l_path) + Result := path_exists (p) + end + end + +note + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/condition/wsf_routing_and_condition.e b/library/server/wsf/router/support/condition/wsf_routing_and_condition.e new file mode 100644 index 00000000..ca0a0a9b --- /dev/null +++ b/library/server/wsf/router/support/condition/wsf_routing_and_condition.e @@ -0,0 +1,43 @@ +note + description: "Summary description for {WSF_ROUTING_AND_CONDITION}." + date: "$Date$" + revision: "$Revision$" + +class + WSF_ROUTING_AND_CONDITION + +inherit + WSF_ROUTING_CONDITION + +create + make + +feature {NONE} -- Creation + + make (a_left, a_right: WSF_ROUTING_CONDITION) + do + left := a_left + right := a_right + end + + left, right: WSF_ROUTING_CONDITION + +feature -- Status report + + accepted (req: WSF_REQUEST): BOOLEAN + -- Does `req` satisfy Current condition? + do + Result := left.accepted (req) and then right.accepted (req) + end + +note + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/condition/wsf_routing_condition.e b/library/server/wsf/router/support/condition/wsf_routing_condition.e new file mode 100644 index 00000000..b01027f6 --- /dev/null +++ b/library/server/wsf/router/support/condition/wsf_routing_condition.e @@ -0,0 +1,39 @@ +note + description: "Summary description for {WSF_ROUTING_CONDITION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_ROUTING_CONDITION + +feature -- Status report + + accepted (req: WSF_REQUEST): BOOLEAN + -- Does `req` satisfy Current condition? + deferred + end + +feature -- Factory + + conjuncted alias "and" (cond: WSF_ROUTING_CONDITION): WSF_ROUTING_AND_CONDITION + do + create Result.make (Current, cond) + end + + disjuncted alias "or" (cond: WSF_ROUTING_CONDITION): WSF_ROUTING_OR_CONDITION + do + create Result.make (Current, cond) + end + +note + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/condition/wsf_routing_or_condition.e b/library/server/wsf/router/support/condition/wsf_routing_or_condition.e new file mode 100644 index 00000000..d175ec7b --- /dev/null +++ b/library/server/wsf/router/support/condition/wsf_routing_or_condition.e @@ -0,0 +1,43 @@ +note + description: "Summary description for {WSF_ROUTING_OR_CONDITION}." + date: "$Date$" + revision: "$Revision$" + +class + WSF_ROUTING_OR_CONDITION + +inherit + WSF_ROUTING_CONDITION + +create + make + +feature {NONE} -- Creation + + make (a_left, a_right: WSF_ROUTING_CONDITION) + do + left := a_left + right := a_right + end + + left, right: WSF_ROUTING_CONDITION + +feature -- Status report + + accepted (req: WSF_REQUEST): BOOLEAN + -- Does `req` satisfy Current condition? + do + Result := left.accepted (req) or else right.accepted (req) + end + +note + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/condition/wsf_with_condition_handler.e b/library/server/wsf/router/support/condition/wsf_with_condition_handler.e new file mode 100644 index 00000000..193d20b1 --- /dev/null +++ b/library/server/wsf/router/support/condition/wsf_with_condition_handler.e @@ -0,0 +1,22 @@ +note + description: "Summary description for {WSF_WITH_CONDITION_HANDLER}." + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_WITH_CONDITION_HANDLER + +inherit + WSF_EXECUTE_HANDLER + +note + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/condition/wsf_with_condition_mapping.e b/library/server/wsf/router/support/condition/wsf_with_condition_mapping.e new file mode 100644 index 00000000..25cd466c --- /dev/null +++ b/library/server/wsf/router/support/condition/wsf_with_condition_mapping.e @@ -0,0 +1,44 @@ +note + description: "Summary description for WSF_WITH_CONDITION_MAPPING." + date: "$Date$" + revision: "$Revision$" + +class + WSF_WITH_CONDITION_MAPPING + +inherit + WSF_WITH_CONDITION_MAPPING_I + +create + make + +feature -- Access + + handler: WSF_EXECUTE_HANDLER + +feature -- change + + set_handler (h: like handler) + do + handler := h + end + +feature {NONE} -- Execution + + execute_handler (h: like handler; req: WSF_REQUEST; res: WSF_RESPONSE) + -- Execute handler `h' with `req' and `res' for Current mapping + do + h.execute (req, res) + end + +note + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/condition/wsf_with_condition_mapping_i.e b/library/server/wsf/router/support/condition/wsf_with_condition_mapping_i.e new file mode 100644 index 00000000..b8bcc5ff --- /dev/null +++ b/library/server/wsf/router/support/condition/wsf_with_condition_mapping_i.e @@ -0,0 +1,109 @@ +note + description: "Summary description for WSF_WITH_CONDITION_MAPPING_I." + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_WITH_CONDITION_MAPPING_I + +inherit + WSF_ROUTER_MAPPING + + WSF_SELF_DOCUMENTED_ROUTER_MAPPING + +feature {NONE} -- Initialization + + make (a_condition: like condition; h: like handler) + do + set_handler (h) + condition := a_condition + end + +feature -- Access + + condition: WSF_ROUTING_CONDITION + + associated_resource: READABLE_STRING_8 + -- Name (URI, or URI template or regular expression or ...) of handled resource + do + if attached condition_description as desc and then desc.is_valid_as_string_8 then + Result := desc.to_string_8 + else + Result := description + end + end + +feature -- Access + + condition_description: detachable READABLE_STRING_32 + +feature -- Element change + + set_condition_description (desc: detachable READABLE_STRING_GENERAL) + do + if desc = Void then + condition_description := Void + else + condition_description := desc.as_string_32 + end + end + + set_handler (h: like handler) + -- Set `handler' to `h'. + require + h_attached: h /= Void + deferred + ensure + h_aliased: handler = h + end + +feature -- Documentation + + description: STRING_32 = "With-Condition" + +feature -- Status + + is_mapping (a_path: READABLE_STRING_8; req: WSF_REQUEST; a_router: WSF_ROUTER): BOOLEAN + -- + do + Result := condition.accepted (req) + end + + try (a_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER) + -- + do + if condition.accepted (req) then + sess.set_dispatched_handler (handler) + a_router.execute_before (Current) + execute_handler (handler, req, res) + a_router.execute_after (Current) + end + end + +feature {NONE} -- Execution + + execute_handler (h: like handler; req: WSF_REQUEST; res: WSF_RESPONSE) + -- Execute handler `h' with `req' and `res' for Current mapping. + require + h_attached: h /= Void + req_attached: req /= Void + res_attached: res /= Void + path_validate_condition: condition.accepted (req) + deferred + end + +invariant + + condition_attached: condition /= Void + +note + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/execute/helpers/wsf_execute_agent_handler.e b/library/server/wsf/router/support/execute/helpers/wsf_execute_agent_handler.e new file mode 100644 index 00000000..c556c73f --- /dev/null +++ b/library/server/wsf/router/support/execute/helpers/wsf_execute_agent_handler.e @@ -0,0 +1,45 @@ +note + description: "Summary description for {WSF_EXECUTE_AGENT_HANDLER}." + date: "$Date$" + revision: "$Revision$" + +class + WSF_EXECUTE_AGENT_HANDLER + +inherit + WSF_HANDLER + + WSF_EXECUTE_HANDLER + +create + make + +feature {NONE} -- Initialization + + make (a_action: like action) + do + action := a_action + end + +feature -- Access + + action: PROCEDURE [TUPLE [request: WSF_REQUEST; response: WSF_RESPONSE]] + +feature -- Execution + + execute (req: WSF_REQUEST; res: WSF_RESPONSE) + do + action (req, res) + end + +note + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/wsf/router/support/execute/helpers/wsf_execute_filter_handler.e b/library/server/wsf/router/support/execute/helpers/wsf_execute_filter_handler.e new file mode 100644 index 00000000..53678008 --- /dev/null +++ b/library/server/wsf/router/support/execute/helpers/wsf_execute_filter_handler.e @@ -0,0 +1,34 @@ +note + description : "Objects that ..." + author : "$Author$" + date : "$Date$" + revision : "$Revision$" + +deferred class + WSF_EXECUTE_FILTER_HANDLER + +inherit + WSF_FILTER_HANDLER [WSF_EXECUTE_HANDLER] + + WSF_EXECUTE_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-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/wsf/router/support/execute/helpers/wsf_execute_response_agent_handler.e b/library/server/wsf/router/support/execute/helpers/wsf_execute_response_agent_handler.e new file mode 100644 index 00000000..a15cadd5 --- /dev/null +++ b/library/server/wsf/router/support/execute/helpers/wsf_execute_response_agent_handler.e @@ -0,0 +1,44 @@ +note + description: "Summary description for {WSF_EXECUTE_RESPONSE_AGENT_HANDLER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_EXECUTE_RESPONSE_AGENT_HANDLER + +inherit + WSF_EXECUTE_RESPONSE_HANDLER + +create + make + +feature -- Initialization + + make (act: like action) + do + action := act + end + +feature -- Access + + action: FUNCTION [TUPLE [req: WSF_REQUEST], WSF_RESPONSE_MESSAGE] + +feature -- Execution + + response (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE + do + Result := action.item ([req]) + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/wsf/router/support/execute/helpers/wsf_execute_response_handler.e b/library/server/wsf/router/support/execute/helpers/wsf_execute_response_handler.e new file mode 100644 index 00000000..4d6c7347 --- /dev/null +++ b/library/server/wsf/router/support/execute/helpers/wsf_execute_response_handler.e @@ -0,0 +1,40 @@ +note + description: "Summary description for {WSF_EXECUTE_RESPONSE_HANDLER}." + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_EXECUTE_RESPONSE_HANDLER + +inherit + WSF_EXECUTE_HANDLER + +feature -- Response + + response (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE + require + is_valid_context: is_valid_context (req) + deferred + ensure + Result_attached: Result /= Void + end + +feature -- Execution + + execute (req: WSF_REQUEST; res: WSF_RESPONSE) + -- Execute request handler + do + res.send (response (req)) + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/wsf/router/support/execute/helpers/wsf_execute_routing_handler.e b/library/server/wsf/router/support/execute/helpers/wsf_execute_routing_handler.e new file mode 100644 index 00000000..7fe93b56 --- /dev/null +++ b/library/server/wsf/router/support/execute/helpers/wsf_execute_routing_handler.e @@ -0,0 +1,28 @@ +note + description: "Summary description for {WSF_EXECUTE_ROUTING_HANDLER}." + date: "$Date$" + revision: "$Revision$" + +class + WSF_EXECUTE_ROUTING_HANDLER + +inherit + WSF_ROUTING_HANDLER + + WSF_EXECUTE_HANDLER + +create + make + + +note + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/wsf/router/support/execute/helpers/wsf_self_documented_execute_agent_handler.e b/library/server/wsf/router/support/execute/helpers/wsf_self_documented_execute_agent_handler.e new file mode 100644 index 00000000..31301f4c --- /dev/null +++ b/library/server/wsf/router/support/execute/helpers/wsf_self_documented_execute_agent_handler.e @@ -0,0 +1,61 @@ +note + description: "Summary description for {WSF_SELF_DOCUMENTED_EXECUTE_AGENT_HANDLER}." + date: "$Date$" + revision: "$Revision$" + +class + WSF_SELF_DOCUMENTED_EXECUTE_AGENT_HANDLER + +inherit + WSF_EXECUTE_AGENT_HANDLER + rename + make as make_handler + end + + WSF_SELF_DOCUMENTED_AGENT_HANDLER + +create + make, + make_with_descriptions, + make_hidden + +feature {NONE} -- Initialization + + make (a_action: like action; a_self_doc: like self_documentation_builder) + -- + -- and using `a_self_doc' function to build the `mapping_documentation'. + do + set_self_documentation_builder (a_self_doc) + make_handler (a_action) + end + + make_with_descriptions (a_action: like action; a_descriptions: ITERABLE [READABLE_STRING_GENERAL]) + do + across + a_descriptions as c + loop + add_description (c.item) + end + make_handler (a_action) + end + + make_hidden (a_action: like action) + -- + -- and using `a_self_doc' function to build the `mapping_documentation' + -- mark it as `hidden'. + do + is_hidden := True + make (a_action, Void) + end + +note + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/wsf/router/support/execute/wsf_execute_handler.e b/library/server/wsf/router/support/execute/wsf_execute_handler.e new file mode 100644 index 00000000..01c47dcc --- /dev/null +++ b/library/server/wsf/router/support/execute/wsf_execute_handler.e @@ -0,0 +1,34 @@ +note + description: "[ + Represents the ancestor of all the WSF_ROUTER handlers with `execute (WSF_REQUEST, WSF_RESPONSE)` routine. + ]" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_EXECUTE_HANDLER + +inherit + WSF_HANDLER + +feature -- Execution + + execute (req: WSF_REQUEST; res: WSF_RESPONSE) + -- Execute `req' responding in `res'. + require + req_attached: req /= Void + res_attached: res /= Void + deferred + end + +note + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/uri/helpers/wsf_self_documented_uri_agent_handler.e b/library/server/wsf/router/support/uri/helpers/wsf_self_documented_uri_agent_handler.e index b47cba25..5f643c93 100644 --- a/library/server/wsf/router/support/uri/helpers/wsf_self_documented_uri_agent_handler.e +++ b/library/server/wsf/router/support/uri/helpers/wsf_self_documented_uri_agent_handler.e @@ -1,6 +1,5 @@ note description: "Summary description for {WSF_SELF_DOCUMENTED_URI_AGENT_HANDLER}." - author: "" date: "$Date$" revision: "$Revision$" @@ -50,7 +49,7 @@ feature {NONE} -- Initialization end note - copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/uri/helpers/wsf_uri_agent_handler.e b/library/server/wsf/router/support/uri/helpers/wsf_uri_agent_handler.e index 98642537..63e748ec 100644 --- a/library/server/wsf/router/support/uri/helpers/wsf_uri_agent_handler.e +++ b/library/server/wsf/router/support/uri/helpers/wsf_uri_agent_handler.e @@ -8,31 +8,14 @@ class WSF_URI_AGENT_HANDLER inherit + WSF_EXECUTE_AGENT_HANDLER WSF_URI_HANDLER create make -feature {NONE} -- Initialization - - make (a_action: like action) - do - action := a_action - end - -feature -- Access - - action: PROCEDURE [TUPLE [request: WSF_REQUEST; response: WSF_RESPONSE]] - -feature -- Execution - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - do - action.call ([req, res]) - end - note - copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/uri/helpers/wsf_uri_filter_handler.e b/library/server/wsf/router/support/uri/helpers/wsf_uri_filter_handler.e index 2758c84a..ab2d7f4e 100644 --- a/library/server/wsf/router/support/uri/helpers/wsf_uri_filter_handler.e +++ b/library/server/wsf/router/support/uri/helpers/wsf_uri_filter_handler.e @@ -8,21 +8,12 @@ deferred class WSF_URI_FILTER_HANDLER inherit - WSF_FILTER_HANDLER [WSF_URI_HANDLER] + WSF_EXECUTE_FILTER_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-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/uri/helpers/wsf_uri_response_agent_handler.e b/library/server/wsf/router/support/uri/helpers/wsf_uri_response_agent_handler.e index 11b02917..7595d696 100644 --- a/library/server/wsf/router/support/uri/helpers/wsf_uri_response_agent_handler.e +++ b/library/server/wsf/router/support/uri/helpers/wsf_uri_response_agent_handler.e @@ -8,31 +8,15 @@ class WSF_URI_RESPONSE_AGENT_HANDLER inherit + WSF_EXECUTE_RESPONSE_AGENT_HANDLER + WSF_URI_RESPONSE_HANDLER create make -feature -- Initialization - - make (act: like action) - do - action := act - end - -feature -- Access - - action: FUNCTION [TUPLE [req: WSF_REQUEST], WSF_RESPONSE_MESSAGE] - -feature -- Execution - - response (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE - do - Result := action.item ([req]) - end - note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/uri/helpers/wsf_uri_response_handler.e b/library/server/wsf/router/support/uri/helpers/wsf_uri_response_handler.e index 07a3b79f..37bb1d59 100644 --- a/library/server/wsf/router/support/uri/helpers/wsf_uri_response_handler.e +++ b/library/server/wsf/router/support/uri/helpers/wsf_uri_response_handler.e @@ -8,28 +8,12 @@ deferred class WSF_URI_RESPONSE_HANDLER inherit + WSF_EXECUTE_HANDLER + WSF_URI_HANDLER -feature -- Response - - response (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE - require - is_valid_context: is_valid_context (req) - deferred - ensure - Result_attached: Result /= Void - end - -feature -- Execution - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - -- Execute request handler - do - res.send (response (req)) - end - note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/uri/wsf_uri_handler.e b/library/server/wsf/router/support/uri/wsf_uri_handler.e index efa5c53c..dc030471 100644 --- a/library/server/wsf/router/support/uri/wsf_uri_handler.e +++ b/library/server/wsf/router/support/uri/wsf_uri_handler.e @@ -8,20 +8,10 @@ deferred class WSF_URI_HANDLER inherit - WSF_HANDLER + WSF_EXECUTE_HANDLER WSF_ROUTER_MAPPING_FACTORY -feature -- Execution - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - -- Execute handler for `req' and respond in `res'. - require - req_attached: req /= Void - res_attached: res /= Void - deferred - end - feature {WSF_ROUTER} -- Mapping new_mapping (a_uri: READABLE_STRING_8): WSF_ROUTER_MAPPING @@ -30,7 +20,7 @@ feature {WSF_ROUTER} -- Mapping end note - copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/uri_template/helpers/wsf_uri_template_agent_handler.e b/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_agent_handler.e index 78f53e0b..cd2dd921 100644 --- a/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_agent_handler.e +++ b/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_agent_handler.e @@ -8,6 +8,8 @@ class WSF_URI_TEMPLATE_AGENT_HANDLER inherit + WSF_EXECUTE_AGENT_HANDLER + WSF_URI_TEMPLATE_HANDLER create @@ -16,26 +18,8 @@ create convert make ({PROCEDURE [WSF_REQUEST, WSF_RESPONSE]}) -feature {NONE} -- Initialization - - make (a_action: like action) - do - action := a_action - end - -feature -- Access - - action: PROCEDURE [TUPLE [request: WSF_REQUEST; response: WSF_RESPONSE]] - -feature -- Execution - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - do - action.call ([req, res]) - end - note - copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/uri_template/helpers/wsf_uri_template_filter_handler.e b/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_filter_handler.e index 8762a0e2..c28005db 100644 --- a/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_filter_handler.e +++ b/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_filter_handler.e @@ -8,21 +8,12 @@ deferred class WSF_URI_TEMPLATE_FILTER_HANDLER inherit - WSF_FILTER_HANDLER [WSF_URI_TEMPLATE_HANDLER] + WSF_EXECUTE_FILTER_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-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/uri_template/helpers/wsf_uri_template_response_agent_handler.e b/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_response_agent_handler.e index 1c2773ee..a5e35a85 100644 --- a/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_response_agent_handler.e +++ b/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_response_agent_handler.e @@ -8,31 +8,15 @@ class WSF_URI_TEMPLATE_RESPONSE_AGENT_HANDLER inherit + WSF_EXECUTE_RESPONSE_AGENT_HANDLER + WSF_URI_TEMPLATE_RESPONSE_HANDLER create make -feature -- Initialization - - make (act: like action) - do - action := act - end - -feature -- Access - - action: FUNCTION [TUPLE [req: WSF_REQUEST], WSF_RESPONSE_MESSAGE] - -feature -- Execution - - response (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE - do - Result := action.item ([req]) - end - note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/uri_template/helpers/wsf_uri_template_response_handler.e b/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_response_handler.e index 4ada70bc..5f1444fa 100644 --- a/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_response_handler.e +++ b/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_response_handler.e @@ -8,28 +8,12 @@ deferred class WSF_URI_TEMPLATE_RESPONSE_HANDLER inherit + WSF_EXECUTE_RESPONSE_HANDLER + WSF_URI_TEMPLATE_HANDLER -feature -- Response - - response (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE - require - is_valid_context: is_valid_context (req) - deferred - ensure - Result_attached: Result /= Void - end - -feature -- Execution - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - -- Execute request handler - do - res.send (response (req)) - end - note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/support/uri_template/wsf_uri_template_handler.e b/library/server/wsf/router/support/uri_template/wsf_uri_template_handler.e index 0e14102c..fc9511df 100644 --- a/library/server/wsf/router/support/uri_template/wsf_uri_template_handler.e +++ b/library/server/wsf/router/support/uri_template/wsf_uri_template_handler.e @@ -8,20 +8,10 @@ deferred class WSF_URI_TEMPLATE_HANDLER inherit - WSF_HANDLER + WSF_EXECUTE_HANDLER WSF_ROUTER_MAPPING_FACTORY -feature -- Execution - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - -- Execute `req' responding in `res'. - require - req_attached: req /= Void - res_attached: res /= Void - deferred - end - feature {WSF_ROUTER} -- Mapping new_mapping (a_tpl: READABLE_STRING_8): WSF_ROUTER_MAPPING @@ -30,7 +20,7 @@ feature {WSF_ROUTER} -- Mapping end note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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/wsf_file_system_handler.e b/library/server/wsf/router/wsf_file_system_handler.e index 65d6a417..1bbad21c 100644 --- a/library/server/wsf/router/wsf_file_system_handler.e +++ b/library/server/wsf/router/wsf_file_system_handler.e @@ -103,7 +103,7 @@ feature -- Access -- Function to evaluate if a path is ignored or not during autoindex. -- If `index_ignores' is Void and `index_ignores_function' is Void, use default ignore rules. - directory_index: detachable ARRAY [READABLE_STRING_8] + directory_index: detachable ITERABLE [READABLE_STRING_GENERAL] -- File serve if a directory index is requested. not_found_handler: detachable PROCEDURE [TUPLE [uri: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE]] @@ -130,7 +130,7 @@ feature -- Element change set_directory_index (idx: like directory_index) -- Set `directory_index' as `idx' do - if idx = Void or else idx.is_empty then + if idx = Void then directory_index := Void else directory_index := idx diff --git a/library/server/wsf/router/wsf_router_mapping.e b/library/server/wsf/router/wsf_router_mapping.e index e3552a16..6c104e93 100644 --- a/library/server/wsf/router/wsf_router_mapping.e +++ b/library/server/wsf/router/wsf_router_mapping.e @@ -11,16 +11,6 @@ deferred class inherit DEBUG_OUTPUT -feature {NONE} -- Initialization - - make (a_resource: READABLE_STRING_8; h: like handler) - -- Create mapping based on resource `a_resource' and handler `h'. - require - a_resource_attached: a_resource /= Void - h_attached: h /= Void - deferred - end - feature -- Access associated_resource: READABLE_STRING_8 diff --git a/library/server/wsf/router/wsf_routing_handler.e b/library/server/wsf/router/wsf_routing_handler.e index 33ae7cfb..153bff9e 100644 --- a/library/server/wsf/router/wsf_routing_handler.e +++ b/library/server/wsf/router/wsf_routing_handler.e @@ -8,7 +8,7 @@ deferred class WSF_ROUTING_HANDLER inherit - WSF_HANDLER + WSF_EXECUTE_HANDLER feature {NONE} -- Initialization