From b93cb17f7c03a42ace5148a194c57a5db16224c7 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 14 Feb 2017 11:21:32 +0100 Subject: [PATCH] Added readme files to the examples. Minor changes in various ecf file and code. Moved filter example under _update_needed since it has obsolete code. --- examples/README.md | 65 +++++++++++++++++++ examples/_update_needed/README.md | 14 ++++ .../filter/filter.ecf} | 14 ++-- .../{ => _update_needed}/filter/license.lic | 0 .../{ => _update_needed}/filter/readme.md | 0 .../filter/src/database/database_api.e | 0 .../filter/src/database/shared_database_api.e | 0 .../filter/src/domain/json_user_converter.e | 0 .../filter/src/domain/user.e | 0 .../filter/src/filter/authentication_filter.e | 0 .../src/filter/filter_handler_context.e | 0 .../filter/src/filter_server.e | 0 .../filter/src/filter_server_execution.e | 0 .../filter/src/resource/user_handler.e | 0 examples/debug/README.md | 1 + examples/obsolete/README.md | 6 ++ examples/proxy/README.md | 6 ++ examples/simple/README.md | 7 ++ examples/simple_file/README.md | 6 ++ examples/simple_ssl/README.md | 5 ++ examples/tutorial/README.wiki | 20 +++--- examples/upload_image/README.md | 6 ++ examples/upload_image/src/image_uploader.e | 4 -- .../src/image_uploader_execution.e | 30 ++------- ...upload_image-safe.ecf => upload_image.ecf} | 0 examples/websocket/README.md | 1 + 26 files changed, 139 insertions(+), 46 deletions(-) create mode 100644 examples/README.md create mode 100644 examples/_update_needed/README.md rename examples/{filter/filter-safe.ecf => _update_needed/filter/filter.ecf} (64%) rename examples/{ => _update_needed}/filter/license.lic (100%) rename examples/{ => _update_needed}/filter/readme.md (100%) rename examples/{ => _update_needed}/filter/src/database/database_api.e (100%) rename examples/{ => _update_needed}/filter/src/database/shared_database_api.e (100%) rename examples/{ => _update_needed}/filter/src/domain/json_user_converter.e (100%) rename examples/{ => _update_needed}/filter/src/domain/user.e (100%) rename examples/{ => _update_needed}/filter/src/filter/authentication_filter.e (100%) rename examples/{ => _update_needed}/filter/src/filter/filter_handler_context.e (100%) rename examples/{ => _update_needed}/filter/src/filter_server.e (100%) rename examples/{ => _update_needed}/filter/src/filter_server_execution.e (100%) rename examples/{ => _update_needed}/filter/src/resource/user_handler.e (100%) create mode 100644 examples/debug/README.md create mode 100644 examples/obsolete/README.md create mode 100644 examples/proxy/README.md create mode 100644 examples/simple/README.md create mode 100644 examples/simple_file/README.md create mode 100644 examples/simple_ssl/README.md create mode 100644 examples/upload_image/README.md rename examples/upload_image/{upload_image-safe.ecf => upload_image.ecf} (100%) create mode 100644 examples/websocket/README.md diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 00000000..61b63885 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,65 @@ +Examples +======== + +This folder contains a few examples demonstrating the EiffelWeb framework solution. + + +## tutorial +This is a step by step tutorial to discover the EiffelWeb framework (EWF). +How to build your first service, access the request data and send the response, also how to use the router to dispatch url easily. + +## simple +This is a very simple system that can be executed as standalone, or hosted as CGI or libFCGI application on Apache, IIS, ... +You will learn how to customize the launcher (port number for standalone, ...), and how to use the interface of `WSF_RESPONSE` to send the response. +(note: in this example, you have to deal with the Content-Type and Content-Length http header, this requires basic knowledge about the http protocol). +[learn more](./simple/README.md) + +## simple_ssl +Almost the same as `simple` example, except this `simple_ssl` example is using only the `standalone` connector, and is supporting `https://` request. You will learn how to configure the .ecf file to add ssl support (see ``), and how to enable it for instance via the `simple.ini` file (imported from the class `APPLICATION`). +[learn more](./simple_ssl/README.md) + +## simple_file +This demonstrates how to return a file to the client. In this example you will learn how to dispatch manually the URL thanks to the `request.path_info` value. +You will also learn how to use the `WSF_RESPONSE.send (message)` interface that does not require you to know that much about http protocol since you will build `WSF_FILE_RESPONSE` and `WSF_NOT_FOUND_MESSAGE` objects. +[learn more](./simple_file/README.md) + +## upload_image +This example shows how to handle file uploading, and also how to use the `WSF_FILE_SYSTEM_HANDLER` to serve local files (i.e a file server component). +It also uses the `WSF_ROUTER` component to route URL based on URI-template declaration. +[learn more](./upload_image/README.md) + +## form +The EiffelWeb framework provides the `wsf_html` library, it is a set of classes to make it easier to generate html using Eiffel code. This includes web form generation, but also web form handling as it analyzes the request data to fill the web form response. +This example shows a simple web form asking for name, birthday, and other radio,checkboxes,combo,file ... input data, and store the result in local directory. +[learn more](./form/README.md) + +## desktop_app +Using the EiffelVision2 embedded web browser component, you will learn how to embed a web server in your GUI application. This way you can run locally a web server and display html pages in the GUI application itself. +[learn more](./desktop_app/README.md) + +## proxy +Via the `wsf_proxy` library, it is possible to implement a simple reverse proxy service. +Note: you need to edit the `application_execution.e` file to use proper remote service. +[learn more](./proxy/README.md) + +## websocket +The EiffelWeb framework provides a websocket server and websocket client solution. This example demonstrates how to build a simple websocket service and consume it from a html+javascript page. This is a very simple chat application. +[learn more](./websocket/README.md) + +## rest +### restbuck CRUD system +Restbuck Eiffel Implementation based on the book of REST in Practice. +This is an implementation of CRUD pattern for manipulate resources, this is the first step to use the HTTP protocol as an application protocol instead of a transport protocol. +[learn more](./rest/restbucks_CRUD/readme.md) + +## debug +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, ...). +[learn more](./debug/README.md) + +## obsolete +A set of example using the old interface of EiffelWeb (i.e version v0). We keep them as example for people having existing project based on EWF v0, but willing to compile with latest EiffelStudio, and latest EWF source code. +[learn more](./obsolete/README.md) + +## _update_needed +This folder contains set of examples that need to be reviewed and updated for various reason. +[learn more](./_update_needed/README.md) diff --git a/examples/_update_needed/README.md b/examples/_update_needed/README.md new file mode 100644 index 00000000..481e269c --- /dev/null +++ b/examples/_update_needed/README.md @@ -0,0 +1,14 @@ +Examples to update +================== + +This folder contains a few examples that needs to be updated. +It could be for many reason +- using obsolete components +- bad style +- not using latest EiffelWeb features +- issue in SCOOP concurrency mode +- ... + +## filter +It demonstrates how to use the `WSF_FILTER` components. It can be used for authentication, and various usage (logging, setting specific http header such as CORS related settings, ...). + diff --git a/examples/filter/filter-safe.ecf b/examples/_update_needed/filter/filter.ecf similarity index 64% rename from examples/filter/filter-safe.ecf rename to examples/_update_needed/filter/filter.ecf index 61856107..5cba3aa5 100644 --- a/examples/filter/filter-safe.ecf +++ b/examples/_update_needed/filter/filter.ecf @@ -11,23 +11,23 @@ - - + + - - - + + + - + - + diff --git a/examples/filter/license.lic b/examples/_update_needed/filter/license.lic similarity index 100% rename from examples/filter/license.lic rename to examples/_update_needed/filter/license.lic diff --git a/examples/filter/readme.md b/examples/_update_needed/filter/readme.md similarity index 100% rename from examples/filter/readme.md rename to examples/_update_needed/filter/readme.md diff --git a/examples/filter/src/database/database_api.e b/examples/_update_needed/filter/src/database/database_api.e similarity index 100% rename from examples/filter/src/database/database_api.e rename to examples/_update_needed/filter/src/database/database_api.e diff --git a/examples/filter/src/database/shared_database_api.e b/examples/_update_needed/filter/src/database/shared_database_api.e similarity index 100% rename from examples/filter/src/database/shared_database_api.e rename to examples/_update_needed/filter/src/database/shared_database_api.e diff --git a/examples/filter/src/domain/json_user_converter.e b/examples/_update_needed/filter/src/domain/json_user_converter.e similarity index 100% rename from examples/filter/src/domain/json_user_converter.e rename to examples/_update_needed/filter/src/domain/json_user_converter.e diff --git a/examples/filter/src/domain/user.e b/examples/_update_needed/filter/src/domain/user.e similarity index 100% rename from examples/filter/src/domain/user.e rename to examples/_update_needed/filter/src/domain/user.e diff --git a/examples/filter/src/filter/authentication_filter.e b/examples/_update_needed/filter/src/filter/authentication_filter.e similarity index 100% rename from examples/filter/src/filter/authentication_filter.e rename to examples/_update_needed/filter/src/filter/authentication_filter.e diff --git a/examples/filter/src/filter/filter_handler_context.e b/examples/_update_needed/filter/src/filter/filter_handler_context.e similarity index 100% rename from examples/filter/src/filter/filter_handler_context.e rename to examples/_update_needed/filter/src/filter/filter_handler_context.e diff --git a/examples/filter/src/filter_server.e b/examples/_update_needed/filter/src/filter_server.e similarity index 100% rename from examples/filter/src/filter_server.e rename to examples/_update_needed/filter/src/filter_server.e diff --git a/examples/filter/src/filter_server_execution.e b/examples/_update_needed/filter/src/filter_server_execution.e similarity index 100% rename from examples/filter/src/filter_server_execution.e rename to examples/_update_needed/filter/src/filter_server_execution.e diff --git a/examples/filter/src/resource/user_handler.e b/examples/_update_needed/filter/src/resource/user_handler.e similarity index 100% rename from examples/filter/src/resource/user_handler.e rename to examples/_update_needed/filter/src/resource/user_handler.e diff --git a/examples/debug/README.md b/examples/debug/README.md new file mode 100644 index 00000000..4ac3d568 --- /dev/null +++ b/examples/debug/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/examples/obsolete/README.md b/examples/obsolete/README.md new file mode 100644 index 00000000..9b612771 --- /dev/null +++ b/examples/obsolete/README.md @@ -0,0 +1,6 @@ +Obsolete example based on EWF v0 +================================ + +Those examples are using the old EWF v0 interface, including use of deprecated "nino" connector. +They serves as example for existing project based on EWF v0, but willing to use latest EiffelStudio, and latest EWF repository. + diff --git a/examples/proxy/README.md b/examples/proxy/README.md new file mode 100644 index 00000000..f3759e7d --- /dev/null +++ b/examples/proxy/README.md @@ -0,0 +1,6 @@ +Proxy example +============= + +Via the `wsf_proxy` library, it is possible to implement a simple reverse proxy service. +Note: you need to edit the `application_execution.e` file to use proper remote service. +(You can use for instance any of the EWF examples as remote server, or also existing public server). diff --git a/examples/simple/README.md b/examples/simple/README.md new file mode 100644 index 00000000..3e1bbad7 --- /dev/null +++ b/examples/simple/README.md @@ -0,0 +1,7 @@ +Simple example +============== + +This is a very simple system that can be executed as standalone, or hosted as CGI or libFCGI application on Apache, IIS, ... +You will learn how to customize the launcher (port number for standalone, ...), and how to use the interface of `WSF_RESPONSE` to send the response. +(note: in this example, you have to deal with the Content-Type and Content-Length http header, this requires basic knowledge about the http protocol). + diff --git a/examples/simple_file/README.md b/examples/simple_file/README.md new file mode 100644 index 00000000..93cbd5bd --- /dev/null +++ b/examples/simple_file/README.md @@ -0,0 +1,6 @@ +File response example +===================== + +This demonstrates how to return a file to the client. In this example you will learn how to dispatch manually the URL thanks to the `request.path_info` value. +You will also learn how to use the `WSF_RESPONSE.send (message)` interface that does not require you to know that much about http protocol since you will build `WSF_FILE_RESPONSE` and `WSF_NOT_FOUND_MESSAGE` objects. + diff --git a/examples/simple_ssl/README.md b/examples/simple_ssl/README.md new file mode 100644 index 00000000..031f092a --- /dev/null +++ b/examples/simple_ssl/README.md @@ -0,0 +1,5 @@ +SSL support with Standalone connector +===================================== + +Almost the same as `simple` example, except this `simple_ssl` example is using only the `standalone` connector, and is supporting `https://` request. You will learn how to configure the .ecf file to add ssl support (see ``), and how to enable it for instance via the `simple.ini` file (imported from the class `APPLICATION`). + diff --git a/examples/tutorial/README.wiki b/examples/tutorial/README.wiki index 87d9c600..31744f7a 100644 --- a/examples/tutorial/README.wiki +++ b/examples/tutorial/README.wiki @@ -1,4 +1,4 @@ -= Eiffel Web Framework = += EiffelWeb Framework = == Why would you use the Eiffel Web Framework ? == @@ -7,28 +7,28 @@ To write once and run on any web server, on any platforms thanks to the notion o == What is a connector? == -A connector is the layer between the underlying httpd server, and your application based on EWF. -Currently, 4 connectors are available within EWF (but others are available outside). -*­ CGI: the common CGI application (apache, iis, ...) +A connector is the layer between the underlying httpd server, and your application based on EiffelWeb. +Currently, 4 connectors are available within EiffelWeb (but others are available outside). +* CGI: the common CGI application (apache, iis, ...) * FastCGI: on any server supporting libfcgi handling (apache, iis, ...) -* Standalone: a standalone Eiffel Web server, it can be run anywhere easily, and debug simply with EiffelStudio's debugger. It supports all concurrency modes, and require EiffelStudio >= 15.05. +* Standalone: a standalone Eiffel Web server, it can be run anywhere easily, and debug simply with EiffelStudio's debugger. It supports all concurrency modes, and require EiffelStudio >= 16.05 -Supporting a new connector is fairly simple, it just has to support the simple EWSGI specification which is really small. Then EWF will bring the power on top of it. +Supporting a new connector is fairly simple, it just has to support the simple EWSGI specification which is really small. Then EiffelWeb will bring the power on top of it. -So you can build your application and be sure you will be able to run it ... anywhere thanks to the conceіpt of connectors. +So you can build your application and be sure you will be able to run it ... anywhere thanks to the concept of connectors. == EWSGI specification == -EWF relies on a small core specification, named EWSGI (Eiffel Web Servєr Gateway Interface). +EiffelWeb relies on a small core specification, named EWSGI (Eiffel Web Server Gateway Interface). It is very limited on purpose to allow building new connector very easily. -For now, you just need to know EWF is compliant with EWSGI specification. +For now, you just need to know EiffelWeb is compliant with EWSGI specification. = Tutorial = Now let's discover the Eiffel Web Framework with this tutorial: -# [[step_1.wiki|Step #1]]: You will learn first, how to get and install EWF. +# [[step_1.wiki|Step #1]]: You will learn first, how to get and install EiffelWeb. # [[step_2.wiki|Step #2]]: build a simple Hello World application # [[step_3.wiki|Step #3]]: use the parameter to build dynamic service # [[step_4.wiki|Step #4]]: And you will learn how to dispatch URL diff --git a/examples/upload_image/README.md b/examples/upload_image/README.md new file mode 100644 index 00000000..14760c0c --- /dev/null +++ b/examples/upload_image/README.md @@ -0,0 +1,6 @@ +Uploading file example +====================== + +This example shows how to handle file uploading, and also how to use the `WSF_FILE_SYSTEM_HANDLER` to serve local files (i.e a file server component). +It also uses the `WSF_ROUTER` component to route URL based on URI-template declaration. + diff --git a/examples/upload_image/src/image_uploader.e b/examples/upload_image/src/image_uploader.e index 28e02cf1..99308ddc 100644 --- a/examples/upload_image/src/image_uploader.e +++ b/examples/upload_image/src/image_uploader.e @@ -8,12 +8,8 @@ class IMAGE_UPLOADER inherit - ANY - WSF_DEFAULT_SERVICE [IMAGE_UPLOADER_EXECUTION] - SHARED_EXECUTION_ENVIRONMENT - create make diff --git a/examples/upload_image/src/image_uploader_execution.e b/examples/upload_image/src/image_uploader_execution.e index 6e5ac13d..2d9da091 100644 --- a/examples/upload_image/src/image_uploader_execution.e +++ b/examples/upload_image/src/image_uploader_execution.e @@ -1,6 +1,5 @@ note description: "Summary description for {IMAGE_UPLOADER_EXECUTION}." - author: "" date: "$Date$" revision: "$Revision$" @@ -11,8 +10,6 @@ inherit WSF_ROUTED_SKELETON_EXECUTION undefine requires_proxy - redefine - initialize end WSF_NO_PROXY_POLICY @@ -26,12 +23,6 @@ create feature {NONE} -- Initialization - initialize - do - Precursor - initialize_router - end - setup_router -- Setup router local @@ -186,32 +177,21 @@ feature {NONE} -- Encoder new_temporary_output_file (n: detachable READABLE_STRING_8): detachable FILE local + ut: WSF_FILE_UTILITIES [RAW_FILE] bp: detachable PATH d: DIRECTORY - i: INTEGER do create bp.make_current create d.make_with_path (bp) if not d.exists then d.recursive_create_dir end + + create ut if n /= Void then - bp := bp.extended ("tmp-download-" + n) + Result := ut.new_temporary_file (d, Void, n) else - bp := bp.extended ("tmp") - end - from - i := 0 - until - Result /= Void or i > 100 - loop - i := i + 1 - create {RAW_FILE} Result.make_with_path (bp.appended ("__" + i.out)) - if Result.exists then - Result := Void - else - Result.open_write - end + Result := ut.new_temporary_file (d, "tmp", Void) end ensure Result /= Void implies Result.is_open_write diff --git a/examples/upload_image/upload_image-safe.ecf b/examples/upload_image/upload_image.ecf similarity index 100% rename from examples/upload_image/upload_image-safe.ecf rename to examples/upload_image/upload_image.ecf diff --git a/examples/websocket/README.md b/examples/websocket/README.md new file mode 100644 index 00000000..1a33e46e --- /dev/null +++ b/examples/websocket/README.md @@ -0,0 +1 @@ +The EiffelWeb framework provides a websocket server and websocket client solution. This example demonstrates how to build a simple websocket service and consume it from a html+javascript page. This is a very simple chat application.