Updated basic documentation
This commit is contained in:
@@ -113,8 +113,6 @@ Im the **APPLICATION_EXECUTION** class class you will need to implement implemen
|
|||||||
|
|
||||||
The WSF_EXECUTION instance, in this case ```APPLICATION_EXECUTION``` is created per request, with two main attributes request: ```WSF_REQUEST``` and response: ```WSF_RESPONSE```.
|
The WSF_EXECUTION instance, in this case ```APPLICATION_EXECUTION``` is created per request, with two main attributes request: ```WSF_REQUEST``` and response: ```WSF_RESPONSE```.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="text"/>
|
<a name="text"/>
|
||||||
## A simple Service to Generate Plain Text.
|
## A simple Service to Generate Plain Text.
|
||||||
|
|
||||||
@@ -122,45 +120,34 @@ Before to continue, it is recommended to review the getting started guided.
|
|||||||
|
|
||||||
```eiffel
|
```eiffel
|
||||||
class
|
class
|
||||||
APPLICATION
|
APPLICATION_EXECUTION
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_DEFAULT_SERVICE
|
WSF_EXECUTION
|
||||||
redefine
|
|
||||||
initialize
|
|
||||||
end
|
|
||||||
|
|
||||||
create
|
create
|
||||||
make_and_launch
|
make
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
|
||||||
|
|
||||||
initialize
|
|
||||||
-- Initialize current service.
|
|
||||||
do
|
|
||||||
set_service_option ("port", 9090)
|
|
||||||
end
|
|
||||||
|
|
||||||
feature -- Basic operations
|
feature -- Basic operations
|
||||||
|
|
||||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
execute
|
||||||
-- Execute the incomming request
|
-- Execute the incomming request
|
||||||
do
|
do
|
||||||
-- To send a response we need to setup, the status code and
|
-- To send a response we need to setup, the status code and
|
||||||
-- the response headers.
|
-- the response headers.
|
||||||
res.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/plain"], ["Content-Length", "11"]>>)
|
response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/plain"], ["Content-Length", "11"]>>)
|
||||||
res.put_string ("Hello World")
|
response.put_string ("Hello World")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
```
|
```
|
||||||
<a name="source_1"></a>
|
<a name="source_1"></a>
|
||||||
##### Source code
|
##### Source code
|
||||||
The source code is available on Github. You can get it by running the command:
|
The source code is available on Github. You can get it by running the command:
|
||||||
|
|
||||||
```git clone https://github.com/EiffelWebFramework/ewf_examples.git```
|
```git clone https://github.com/EiffelWebFramework/ewf.git```
|
||||||
|
|
||||||
The example of simple service that generate plain text response is located in the directory $PATH/ewf_examples/workbook/basics/simple, where $PATH is where you run ```git clone``` . Just double click on the simple.ecf file and select the simple_nino target or if you prefer the command line, run the command:
|
The example of simple service that generate plain text response is located in the directory $PATH/ewd/doc/workbook/basics/simple, where $PATH is where you run ```git clone``` . Just double click on the simple.ecf file and select the simple_nino target or if you prefer the command line, run the command:
|
||||||
|
|
||||||
```estudio -config simple.ecf -target simple_nino```
|
```estudio -config simple.ecf -target simple_nino```
|
||||||
|
|
||||||
@@ -173,37 +160,25 @@ To generate HTML, it's needed
|
|||||||
|
|
||||||
```eiffel
|
```eiffel
|
||||||
class
|
class
|
||||||
APPLICATION
|
APPLICATION_EXECUTION
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_DEFAULT_SERVICE
|
WSF_EXECUTION
|
||||||
redefine
|
|
||||||
initialize
|
|
||||||
end
|
|
||||||
|
|
||||||
create
|
create
|
||||||
make_and_launch
|
make
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
|
||||||
|
|
||||||
initialize
|
|
||||||
-- Initialize current service.
|
|
||||||
do
|
|
||||||
set_service_option ("port", 9090)
|
|
||||||
end
|
|
||||||
|
|
||||||
feature -- Basic operations
|
feature -- Basic operations
|
||||||
|
|
||||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
execute
|
||||||
-- Execute the incomming request
|
-- Execute the incomming request
|
||||||
do
|
do
|
||||||
-- To send a response we need to setup, the status code and
|
-- To send a response we need to setup, the status code and
|
||||||
-- the response headers.
|
-- the response headers.
|
||||||
res.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/html"], ["Content-Length", web_page.count.out]>>)
|
response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/html"], ["Content-Length", web_page.count.out]>>)
|
||||||
res.put_string (web_page)
|
response.put_string (web_page)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
web_page: STRING = "[
|
web_page: STRING = "[
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@@ -221,9 +196,9 @@ end
|
|||||||
##### Source code
|
##### Source code
|
||||||
The source code is available on Github. You can get it by running the command:
|
The source code is available on Github. You can get it by running the command:
|
||||||
|
|
||||||
```git clone https://github.com/EiffelWebFramework/ewf_examples.git```
|
```git clone https://github.com/EiffelWebFramework/ewf.git```
|
||||||
|
|
||||||
The example of the service that generates HTML is located in the directory $PATH/ewf_examples/workbook/basics/simple_html, where $PATH is where you run ```git clone``` . Just double click on the simple_html.ecf file and select the simple_html_nino target or if you prefer the command line, run the command:
|
The example of the service that generates HTML is located in the directory $PATH/ewf/doc/workbook/basics/simple_html, where $PATH is where you run ```git clone``` . Just double click on the simple_html.ecf file and select the simple_html_nino target or if you prefer the command line, run the command:
|
||||||
|
|
||||||
```estudio -config simple_html.ecf -target simple_html_nino```
|
```estudio -config simple_html.ecf -target simple_html_nino```
|
||||||
|
|
||||||
|
|||||||
@@ -22,5 +22,4 @@ feature -- Basic operations
|
|||||||
response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/plain"], ["Content-Length", "11"]>>)
|
response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/plain"], ["Content-Length", "11"]>>)
|
||||||
response.put_string ("Hello World")
|
response.put_string ("Hello World")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user