diff --git a/draft/library/server/wsf_js_widget/examples/demo/application_execution.e b/draft/library/server/wsf_js_widget/examples/demo/application_execution.e index 564f5c85..f52ea971 100644 --- a/draft/library/server/wsf_js_widget/examples/demo/application_execution.e +++ b/draft/library/server/wsf_js_widget/examples/demo/application_execution.e @@ -38,14 +38,14 @@ feature -- Router and Filter -- NOTE: you could put all those files in a specific folder, and use WSF_FILE_SYSTEM_HANDLER with "/" -- this way, it handles the caching and so on - router.handle_with_request_methods ("/assets", create {WSF_FILE_SYSTEM_HANDLER}.make_hidden ("assets"), router.methods_GET) + router.handle ("/assets", create {WSF_FILE_SYSTEM_HANDLER}.make_hidden ("assets"), router.methods_GET) end feature -- Helper: mapping map_agent_uri (a_uri: READABLE_STRING_8; a_action: like {WSF_URI_AGENT_HANDLER}.action; rqst_methods: detachable WSF_REQUEST_METHODS) do - router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, create {WSF_URI_AGENT_HANDLER}.make (a_action)), rqst_methods) + router.map (create {WSF_URI_MAPPING}.make (a_uri, create {WSF_URI_AGENT_HANDLER}.make (a_action)), rqst_methods) end feature -- Execution diff --git a/examples/debug/debug.ecf b/examples/debug/debug.ecf index 5c6d642c..948e3e8e 100644 --- a/examples/debug/debug.ecf +++ b/examples/debug/debug.ecf @@ -18,7 +18,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/examples/desktop_app/desktop_app.ecf b/examples/desktop_app/desktop_app.ecf index 81a0aa50..6ba18b3f 100644 --- a/examples/desktop_app/desktop_app.ecf +++ b/examples/desktop_app/desktop_app.ecf @@ -7,7 +7,7 @@ - + diff --git a/examples/desktop_app/src/app_embedded_web_execution.e b/examples/desktop_app/src/app_embedded_web_execution.e index 815e35a6..50f0a87a 100644 --- a/examples/desktop_app/src/app_embedded_web_execution.e +++ b/examples/desktop_app/src/app_embedded_web_execution.e @@ -45,11 +45,11 @@ feature -- Execution req := request create router.make (3) - router.handle ("/test/{var}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_test)) - router.handle ("/env", create {WSF_URI_AGENT_HANDLER}.make (agent handle_env)) - router.handle ("/exit", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_exit)) + router.handle ("/test/{var}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_test), Void) + router.handle ("/env", create {WSF_URI_AGENT_HANDLER}.make (agent handle_env), Void) + router.handle ("/exit", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_exit), Void) create fs.make_with_path ((create {EXECUTION_ENVIRONMENT}).current_working_path.extended ("files")) - router.handle ("/files", fs) + router.handle ("/files", fs, Void) create sess router.dispatch (req, response, sess) if not sess.dispatched then diff --git a/examples/filter/filter-safe.ecf b/examples/filter/filter-safe.ecf index 6d85dcd0..cf802a06 100644 --- a/examples/filter/filter-safe.ecf +++ b/examples/filter/filter-safe.ecf @@ -27,7 +27,7 @@ - + diff --git a/examples/filter/src/filter_server_execution.e b/examples/filter/src/filter_server_execution.e index 21727ede..4081d291 100644 --- a/examples/filter/src/filter_server_execution.e +++ b/examples/filter/src/filter_server_execution.e @@ -59,7 +59,7 @@ feature {NONE} -- Initialization create l_methods l_methods.enable_options l_methods.enable_get - router.handle_with_request_methods ("/user/{userid}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent l_options_filter.execute), l_methods) + router.handle ("/user/{userid}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent l_options_filter.execute), l_methods) end initialize_json diff --git a/examples/restbucksCRUD/restbucks-safe.ecf b/examples/restbucksCRUD/restbucks-safe.ecf index acf2f5dd..9a8a9a6e 100644 --- a/examples/restbucksCRUD/restbucks-safe.ecf +++ b/examples/restbucksCRUD/restbucks-safe.ecf @@ -8,7 +8,7 @@ - + - + diff --git a/examples/simple_file/service_file.ecf b/examples/simple_file/service_file.ecf index 9674713e..7f39a526 100644 --- a/examples/simple_file/service_file.ecf +++ b/examples/simple_file/service_file.ecf @@ -5,7 +5,7 @@ - + diff --git a/examples/upload_image/src/image_uploader_execution.e b/examples/upload_image/src/image_uploader_execution.e index 06161243..6e5ac13d 100644 --- a/examples/upload_image/src/image_uploader_execution.e +++ b/examples/upload_image/src/image_uploader_execution.e @@ -37,13 +37,13 @@ feature {NONE} -- Initialization local www: WSF_FILE_SYSTEM_HANDLER do - map_uri_template_agent_with_request_methods ("/upload/{name}{?nb}", agent execute_upload_put, router.methods_put) + map_uri_template_agent ("/upload/{name}{?nb}", agent execute_upload_put, router.methods_put) map_uri_template_agent ("/upload{?nb}", agent execute_upload, Void) create www.make_with_path (document_root) www.set_directory_index (<<"index.html">>) www.set_not_found_handler (agent execute_not_found) - router.handle_with_request_methods ("", www, router.methods_GET) + router.handle ("", www, router.methods_GET) end feature -- Configuration diff --git a/library/server/wsf/router/support/uri/helpers/wsf_routed_uri_helper.e b/library/server/wsf/router/support/uri/helpers/wsf_routed_uri_helper.e index b2c5bfe9..e44ef2b5 100644 --- a/library/server/wsf/router/support/uri/helpers/wsf_routed_uri_helper.e +++ b/library/server/wsf/router/support/uri/helpers/wsf_routed_uri_helper.e @@ -11,16 +11,18 @@ inherit feature -- Mapping helper: uri - map_uri (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER) - -- Map `h' as handler for `a_uri' + map_uri (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS) + -- Map `h' as handler for `a_uri', according to `rqst_methods'. do - map_uri_with_request_methods (a_uri, h, Void) + router.map (create {WSF_URI_MAPPING}.make (a_uri, h), rqst_methods) end map_uri_with_request_methods (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS) -- Map `h' as handler for `a_uri' for request methods `rqst_methods'. + obsolete + "Use directly `map_uri' [June/2015]" do - router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, h), rqst_methods) + map_uri (a_uri, h, rqst_methods) end map_uri_response (a_uri: READABLE_STRING_8; h: WSF_URI_RESPONSE_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS) @@ -28,21 +30,23 @@ feature -- Mapping helper: uri require h_attached: h /= Void do - router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, h), rqst_methods) + router.map (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]]) - -- Map `proc' as handler for `a_uri' + map_uri_agent (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS) + -- Map `proc' as handler for `a_uri', according to `rqst_methods'. do - map_uri_agent_with_request_methods (a_uri, proc, Void) + map_uri (a_uri, create {WSF_URI_AGENT_HANDLER}.make (proc), rqst_methods) 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_REQUEST_METHODS) -- Map `proc' as handler for `a_uri' for request methods `rqst_methods'. + obsolete + "Use directly `map_uri_agent' [June/2015]" do - map_uri_with_request_methods (a_uri, create {WSF_URI_AGENT_HANDLER}.make (proc), rqst_methods) + map_uri_agent (a_uri, proc, rqst_methods) end map_uri_response_agent (a_uri: READABLE_STRING_8; a_action: like {WSF_URI_RESPONSE_AGENT_HANDLER}.action; rqst_methods: detachable WSF_REQUEST_METHODS) diff --git a/library/server/wsf/router/support/uri_template/helpers/wsf_routed_uri_template_helper.e b/library/server/wsf/router/support/uri_template/helpers/wsf_routed_uri_template_helper.e index 12152825..76f8d7ea 100644 --- a/library/server/wsf/router/support/uri_template/helpers/wsf_routed_uri_template_helper.e +++ b/library/server/wsf/router/support/uri_template/helpers/wsf_routed_uri_template_helper.e @@ -12,7 +12,7 @@ inherit feature -- Mapping helper: uri template map_uri_template (a_tpl: STRING; h: WSF_URI_TEMPLATE_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS) - -- Map `h' as handler for `a_tpl'. + -- Map `h' as handler for `a_tpl', according to `rqst_methods'. require a_tpl_attached: a_tpl /= Void h_attached: h /= Void @@ -43,7 +43,7 @@ feature -- Mapping helper: uri template feature -- Mapping helper: uri template agent map_uri_template_agent (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS) - -- Map `proc' as handler for `a_tpl' + -- Map `proc' as handler for `a_tpl', according to `rqst_methods'. require a_tpl_attached: a_tpl /= Void proc_attached: proc /= Void diff --git a/library/server/wsf/router/wsf_router.e b/library/server/wsf/router/wsf_router.e index 4b6e2deb..78293969 100644 --- a/library/server/wsf/router/wsf_router.e +++ b/library/server/wsf/router/wsf_router.e @@ -65,11 +65,13 @@ feature {NONE} -- Initialization feature -- Mapping map (a_mapping: WSF_ROUTER_MAPPING; rqst_methods: detachable WSF_REQUEST_METHODS) - -- Map `a_mapping'. + -- Map `a_mapping', + -- if `rqst_methods' is set, accept only request method in `rqst_methods'. + -- if `rqst_method' is Void, accept any request methods. require a_mapping_attached: a_mapping /= Void do - extend (create {WSF_ROUTER_ITEM}.make_with_request_methods (a_mapping, rqst_methods)) + extend (create {WSF_ROUTER_ITEM}.make (a_mapping, rqst_methods)) end map_with_request_methods (a_mapping: WSF_ROUTER_MAPPING; rqst_methods: detachable WSF_REQUEST_METHODS) @@ -120,6 +122,8 @@ feature -- Mapping handler handle (a_resource: READABLE_STRING_8; f: WSF_ROUTER_MAPPING_FACTORY; rqst_methods: detachable WSF_REQUEST_METHODS) -- Map the mapping created by factory `f' for resource `a_resource'. + -- if `rqst_methods' is set, accept only request method in `rqst_methods'. + -- if `rqst_method' is Void, accept any request methods. require a_resource_attached: a_resource /= Void f_attached: f /= Void diff --git a/library/server/wsf/router/wsf_router_item.e b/library/server/wsf/router/wsf_router_item.e index 00467390..c385d3bc 100644 --- a/library/server/wsf/router/wsf_router_item.e +++ b/library/server/wsf/router/wsf_router_item.e @@ -16,19 +16,13 @@ inherit DEBUG_OUTPUT create - make, - make_with_request_methods + make feature {NONE} -- Initialization - make (m: like mapping) + make (m: like mapping; r: like request_methods) do mapping := m - end - - make_with_request_methods (m: like mapping; r: like request_methods) - do - make (m) set_request_methods (r) end @@ -71,7 +65,7 @@ invariant mapping_attached: mapping /= Void note - copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" + copyright: "2011-2015, 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_context/support/starts_with/helpers/wsf_starts_with_context_router_helper.e b/library/server/wsf/router_context/support/starts_with/helpers/wsf_starts_with_context_router_helper.e index 77f53f32..2c219aef 100644 --- a/library/server/wsf/router_context/support/starts_with/helpers/wsf_starts_with_context_router_helper.e +++ b/library/server/wsf/router_context/support/starts_with/helpers/wsf_starts_with_context_router_helper.e @@ -14,42 +14,46 @@ feature -- Access feature -- Mapping helper: starts_with - map_starts_with (a_uri: READABLE_STRING_8; h: WSF_STARTS_WITH_CONTEXT_HANDLER [C]) + map_starts_with (a_uri: READABLE_STRING_8; h: WSF_STARTS_WITH_CONTEXT_HANDLER [C]; rqst_methods: detachable WSF_REQUEST_METHODS) require a_uri_attached: a_uri /= Void h_attached: h /= Void do - map_starts_with_request_methods (a_uri, h, Void) + router.map (create {WSF_STARTS_WITH_CONTEXT_MAPPING [C]}.make (a_uri, h), rqst_methods) end map_starts_with_request_methods (a_uri: READABLE_STRING_8; h: WSF_STARTS_WITH_CONTEXT_HANDLER [C]; rqst_methods: detachable WSF_REQUEST_METHODS) + obsolete + "Use directly `map_starts_with' [June-2015]" require a_uri_attached: a_uri /= Void h_attached: h /= Void do - router.map_with_request_methods (create {WSF_STARTS_WITH_CONTEXT_MAPPING [C]}.make (a_uri, h), rqst_methods) + map_starts_with (a_uri, h, rqst_methods) end feature -- Mapping helper: starts_with agent - map_starts_with_agent (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [start_path: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]) + map_starts_with_agent (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [start_path: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS) require a_uri_attached: a_uri /= Void proc_attached: proc /= Void do - map_starts_with_agent_with_request_methods (a_uri, proc, Void) + map_starts_with (a_uri, create {WSF_STARTS_WITH_AGENT_CONTEXT_HANDLER [C] }.make (proc), rqst_methods) end map_starts_with_agent_with_request_methods (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [start_path: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS) + obsolete + "Use directly `map_starts_with_agent' [June-2015]" require a_uri_attached: a_uri /= Void proc_attached: proc /= Void do - map_starts_with_request_methods (a_uri, create {WSF_STARTS_WITH_AGENT_CONTEXT_HANDLER [C] }.make (proc), rqst_methods) + map_starts_with_agent (a_uri, proc, rqst_methods) end note - copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" + copyright: "2011-2015, 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_context/support/uri/helpers/wsf_uri_context_router_helper.e b/library/server/wsf/router_context/support/uri/helpers/wsf_uri_context_router_helper.e index 8d5baa5b..239beeba 100644 --- a/library/server/wsf/router_context/support/uri/helpers/wsf_uri_context_router_helper.e +++ b/library/server/wsf/router_context/support/uri/helpers/wsf_uri_context_router_helper.e @@ -14,42 +14,46 @@ feature -- Access feature -- Mapping helper: uri - map_uri (a_uri: READABLE_STRING_8; h: WSF_URI_CONTEXT_HANDLER [C]) + map_uri (a_uri: READABLE_STRING_8; h: WSF_URI_CONTEXT_HANDLER [C]; rqst_methods: detachable WSF_REQUEST_METHODS) require a_uri_attached: a_uri /= Void h_attached: h /= Void do - map_uri_with_request_methods (a_uri, h, Void) + router.map (create {WSF_URI_CONTEXT_MAPPING [C]}.make (a_uri, h), rqst_methods) end map_uri_with_request_methods (a_uri: READABLE_STRING_8; h: WSF_URI_CONTEXT_HANDLER [C]; rqst_methods: detachable WSF_REQUEST_METHODS) + obsolete + "Use directly `map_uri' [June-2015]" require a_uri_attached: a_uri /= Void h_attached: h /= Void do - router.map_with_request_methods (create {WSF_URI_CONTEXT_MAPPING [C]}.make (a_uri, h), rqst_methods) + map_uri (a_uri, h, rqst_methods) end feature -- Mapping helper: uri agent - map_uri_agent (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]) + map_uri_agent (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS) require a_uri_attached: a_uri /= Void proc_attached: proc /= Void do - map_uri_agent_with_request_methods (a_uri, proc, Void) + map_uri (a_uri, create {WSF_URI_AGENT_CONTEXT_HANDLER [C] }.make (proc), rqst_methods) end map_uri_agent_with_request_methods (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS) + obsolete + "Use directly `map_uri_agent' [June-2015]" require a_uri_attached: a_uri /= Void proc_attached: proc /= Void do - map_uri_with_request_methods (a_uri, create {WSF_URI_AGENT_CONTEXT_HANDLER [C] }.make (proc), rqst_methods) + map_uri_agent (a_uri, proc, rqst_methods) end note - copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" + copyright: "2011-2015, 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_context/support/uri_template/helpers/wsf_uri_template_context_router_helper.e b/library/server/wsf/router_context/support/uri_template/helpers/wsf_uri_template_context_router_helper.e index e3969420..bf1c5d56 100644 --- a/library/server/wsf/router_context/support/uri_template/helpers/wsf_uri_template_context_router_helper.e +++ b/library/server/wsf/router_context/support/uri_template/helpers/wsf_uri_template_context_router_helper.e @@ -14,42 +14,46 @@ feature -- Access feature -- Mapping helper: uri - map_uri_template (a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_CONTEXT_HANDLER [C]) + map_uri_template (a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_CONTEXT_HANDLER [C]; rqst_methods: detachable WSF_REQUEST_METHODS) require a_tpl_attached: a_tpl /= Void h_attached: h /= Void do - map_uri_template_with_request_methods (a_tpl, h, Void) + router.map (create {WSF_URI_TEMPLATE_CONTEXT_MAPPING [C]}.make (a_tpl, h), rqst_methods) end map_uri_template_with_request_methods (a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_CONTEXT_HANDLER [C]; rqst_methods: detachable WSF_REQUEST_METHODS) + obsolete + "Use directly `make_uri_template' [June/2015]" require a_tpl_attached: a_tpl /= Void h_attached: h /= Void do - router.map_with_request_methods (create {WSF_URI_TEMPLATE_CONTEXT_MAPPING [C]}.make (a_tpl, h), rqst_methods) + map_uri_template (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: C; req: WSF_REQUEST; res: WSF_RESPONSE]]) + map_uri_template_agent (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS) require a_tpl_attached: a_tpl /= Void proc_attached: proc /= Void do - map_uri_template_agent_with_request_methods (a_tpl, proc, Void) + map_uri_template (a_tpl, create {WSF_URI_TEMPLATE_AGENT_CONTEXT_HANDLER [C] }.make (proc), rqst_methods) end map_uri_template_agent_with_request_methods (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS) + obsolete + "Use directly `make_uri_template_agent' [June/2015]" require a_tpl_attached: a_tpl /= Void proc_attached: proc /= Void do - map_uri_template_with_request_methods (a_tpl, create {WSF_URI_TEMPLATE_AGENT_CONTEXT_HANDLER [C] }.make (proc), rqst_methods) + map_uri_template_agent (a_tpl, proc, rqst_methods) end note - copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" + copyright: "2011-2015, 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