From b81f690d0c1a3e37923a1862e4fee8b9141b87a8 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 11 Jul 2017 23:41:08 +0200 Subject: [PATCH] First test to implement a requestbin like service with Eiffel. --- tools/requestbin/README.md | 1 + .../launcher/any/application_launcher.e | 19 ++++ .../launcher/any/application_launcher_i.e | 102 ++++++++++++++++++ .../launcher/default/application_launcher.e | 19 ++++ .../launcher/default/application_launcher_i.e | 26 +++++ tools/requestbin/requestbin.ecf | 48 +++++++++ tools/requestbin/server.ini | 2 + tools/requestbin/src/ewf_debug_execution.e | 27 +++++ tools/requestbin/src/ewf_requestbin_server.e | 35 ++++++ 9 files changed, 279 insertions(+) create mode 100644 tools/requestbin/README.md create mode 100644 tools/requestbin/launcher/any/application_launcher.e create mode 100644 tools/requestbin/launcher/any/application_launcher_i.e create mode 100644 tools/requestbin/launcher/default/application_launcher.e create mode 100644 tools/requestbin/launcher/default/application_launcher_i.e create mode 100644 tools/requestbin/requestbin.ecf create mode 100644 tools/requestbin/server.ini create mode 100644 tools/requestbin/src/ewf_debug_execution.e create mode 100644 tools/requestbin/src/ewf_requestbin_server.e diff --git a/tools/requestbin/README.md b/tools/requestbin/README.md new file mode 100644 index 00000000..4ac3d568 --- /dev/null +++ b/tools/requestbin/README.md @@ -0,0 +1 @@ +This example is a simple service that analyze the request and return a formatted output of the request data (query parameters, form parameters, environment variables, and so on). It could be used to debug client, or to experiment the EiffelWeb behavior on various connectors (standalone, apache, iis, ...). diff --git a/tools/requestbin/launcher/any/application_launcher.e b/tools/requestbin/launcher/any/application_launcher.e new file mode 100644 index 00000000..bb184d0a --- /dev/null +++ b/tools/requestbin/launcher/any/application_launcher.e @@ -0,0 +1,19 @@ +note + description: "[ + Effective class for APPLICATION_LAUNCHER_I + + You can put modification in this class + ]" + date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $" + revision: "$Revision: 36 $" + +class + APPLICATION_LAUNCHER [G -> WSF_EXECUTION create make end] + +inherit + APPLICATION_LAUNCHER_I [G] + +feature -- Custom + +end + diff --git a/tools/requestbin/launcher/any/application_launcher_i.e b/tools/requestbin/launcher/any/application_launcher_i.e new file mode 100644 index 00000000..570f8e20 --- /dev/null +++ b/tools/requestbin/launcher/any/application_launcher_i.e @@ -0,0 +1,102 @@ +note + description: "[ + Specific application launcher + + DO NOT EDIT THIS CLASS + + you can customize APPLICATION_LAUNCHER + ]" + date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $" + revision: "$Revision: 36 $" + +deferred class + APPLICATION_LAUNCHER_I [G -> WSF_EXECUTION create make end] + +inherit + SHARED_EXECUTION_ENVIRONMENT + +feature -- Execution + + launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS) + local + nature: like launcher_nature + do + nature := launcher_nature + if nature = Void or else nature = nature_standalone then + launch_standalone (opts) + elseif nature = nature_cgi then + launch_cgi (opts) + elseif nature = nature_libfcgi then + launch_libfcgi (opts) + else + -- bye bye + (create {EXCEPTIONS}).die (-1) + end + end + +feature {NONE} -- Access + + launcher_nature: detachable READABLE_STRING_8 + -- Initialize the launcher nature + -- either cgi, libfcgi, or standalone. + --| We could extend with more connector if needed. + --| and we could use WSF_DEFAULT_SERVICE_LAUNCHER to configure this at compilation time. + local + p: PATH + ext: detachable READABLE_STRING_32 + do + create p.make_from_string (execution_environment.arguments.command_name) + if attached p.entry as l_entry then + ext := l_entry.extension + end + if ext /= Void then + if ext.same_string (nature_standalone) then + Result := nature_standalone + end + if ext.same_string (nature_cgi) then + Result := nature_cgi + end + if ext.same_string (nature_libfcgi) or else ext.same_string ("fcgi") then + Result := nature_libfcgi + end + end + Result := nature_standalone + end + +feature {NONE} -- Standalone + + nature_standalone: STRING = "standalone" + + launch_standalone (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS) + local + launcher: WSF_STANDALONE_SERVICE_LAUNCHER [G] + do + create launcher.make_and_launch (opts) + end + +feature {NONE} -- cgi + + nature_cgi: STRING = "cgi" + + launch_cgi (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS) + local + launcher: WSF_CGI_SERVICE_LAUNCHER [G] + do + create launcher.make_and_launch (opts) + end + +feature {NONE} -- libfcgi + + nature_libfcgi: STRING = "libfcgi" + + launch_libfcgi (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS) + local + launcher: WSF_LIBFCGI_SERVICE_LAUNCHER [G] + do + create launcher.make_and_launch (opts) + end + + +end + + diff --git a/tools/requestbin/launcher/default/application_launcher.e b/tools/requestbin/launcher/default/application_launcher.e new file mode 100644 index 00000000..bb184d0a --- /dev/null +++ b/tools/requestbin/launcher/default/application_launcher.e @@ -0,0 +1,19 @@ +note + description: "[ + Effective class for APPLICATION_LAUNCHER_I + + You can put modification in this class + ]" + date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $" + revision: "$Revision: 36 $" + +class + APPLICATION_LAUNCHER [G -> WSF_EXECUTION create make end] + +inherit + APPLICATION_LAUNCHER_I [G] + +feature -- Custom + +end + diff --git a/tools/requestbin/launcher/default/application_launcher_i.e b/tools/requestbin/launcher/default/application_launcher_i.e new file mode 100644 index 00000000..ef8f0037 --- /dev/null +++ b/tools/requestbin/launcher/default/application_launcher_i.e @@ -0,0 +1,26 @@ +note + description: "[ + Specific application launcher + + DO NOT EDIT THIS CLASS + + you can customize APPLICATION_LAUNCHER + ]" + date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $" + revision: "$Revision: 36 $" + +deferred class + APPLICATION_LAUNCHER_I [G -> WSF_EXECUTION create make end] + +feature -- Execution + + launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS) + local + launcher: WSF_SERVICE_LAUNCHER [G] + do + create {WSF_DEFAULT_SERVICE_LAUNCHER [G]} launcher.make_and_launch (opts) + end + +end + + diff --git a/tools/requestbin/requestbin.ecf b/tools/requestbin/requestbin.ecf new file mode 100644 index 00000000..9d42f0fd --- /dev/null +++ b/tools/requestbin/requestbin.ecf @@ -0,0 +1,48 @@ + + + + + /.svn$ + /CVS$ + /EIFGENs$ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/requestbin/server.ini b/tools/requestbin/server.ini new file mode 100644 index 00000000..abab4e03 --- /dev/null +++ b/tools/requestbin/server.ini @@ -0,0 +1,2 @@ +port=9090 +verbose=true diff --git a/tools/requestbin/src/ewf_debug_execution.e b/tools/requestbin/src/ewf_debug_execution.e new file mode 100644 index 00000000..f75c44c2 --- /dev/null +++ b/tools/requestbin/src/ewf_debug_execution.e @@ -0,0 +1,27 @@ +note + description: "Summary description for {EWF_DEBUG_EXECUTION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + EWF_DEBUG_EXECUTION + +inherit + WSF_EXECUTION + +create + make + +feature -- Execution + + execute + local + dbg: WSF_DEBUG_HANDLER + do + response.put_error ("DEBUG uri=" + request.request_uri + "%N") + create dbg.make + dbg.execute_starts_with ("", request, response) + end + +end diff --git a/tools/requestbin/src/ewf_requestbin_server.e b/tools/requestbin/src/ewf_requestbin_server.e new file mode 100644 index 00000000..89a9f24a --- /dev/null +++ b/tools/requestbin/src/ewf_requestbin_server.e @@ -0,0 +1,35 @@ +note + description: "[ + application service + ]" + date: "$Date$" + revision: "$Revision$" + +class + EWF_REQUESTBIN_SERVER + +inherit + WSF_LAUNCHABLE_SERVICE + redefine + initialize + end + + APPLICATION_LAUNCHER [EWF_DEBUG_EXECUTION] + +create + make_and_launch + +feature {NONE} -- Initialization + + initialize + -- Initialize current service. + do + Precursor +-- set_service_option ("verbose", True) + set_service_option ("port", 9090) +-- set_service_option ("base", "/www-debug/debug_service.fcgi/") + import_service_options (create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI}.make_from_file ("server.ini")) + end + +end +