Make a simple hello world based on nino
This commit is contained in:
@@ -0,0 +1,64 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {GW_NINO_APPLICATION}."
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
GW_NINO_APPLICATION
|
||||||
|
|
||||||
|
create
|
||||||
|
make,
|
||||||
|
make_custom
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
|
make (a_callback: like {GW_AGENT_APPLICATION}.callback)
|
||||||
|
-- Initialize `Current'.
|
||||||
|
do
|
||||||
|
make_custom (a_callback, Void)
|
||||||
|
end
|
||||||
|
|
||||||
|
make_custom (a_callback: like {GW_AGENT_APPLICATION}.callback; a_base_url: detachable STRING)
|
||||||
|
-- Initialize `Current'.
|
||||||
|
local
|
||||||
|
app: GW_AGENT_APPLICATION
|
||||||
|
do
|
||||||
|
create app.make (a_callback)
|
||||||
|
create connector.make_with_base (app, a_base_url)
|
||||||
|
end
|
||||||
|
|
||||||
|
connector: GW_NINO_CONNECTOR
|
||||||
|
-- Web server connector
|
||||||
|
|
||||||
|
feature -- Status settings
|
||||||
|
|
||||||
|
configuration: HTTP_SERVER_CONFIGURATION
|
||||||
|
do
|
||||||
|
Result := connector.configuration
|
||||||
|
end
|
||||||
|
|
||||||
|
force_single_threaded
|
||||||
|
-- Force single threaded behavior
|
||||||
|
do
|
||||||
|
configuration.force_single_threaded := True
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Server
|
||||||
|
|
||||||
|
listen (a_port: INTEGER)
|
||||||
|
do
|
||||||
|
configuration.http_server_port := a_port
|
||||||
|
connector.launch
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2011, 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
|
||||||
@@ -9,11 +9,10 @@
|
|||||||
</file_rule>
|
</file_rule>
|
||||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
|
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
|
||||||
</option>
|
</option>
|
||||||
|
<setting name="concurrency" value="thread"/>
|
||||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
|
|
||||||
<library name="connector_cgi" location="..\..\connectors\cgi\cgi-safe.ecf" readonly="false"/>
|
|
||||||
<library name="connector_nino" location="..\..\connectors\nino\nino-safe.ecf" readonly="false"/>
|
<library name="connector_nino" location="..\..\connectors\nino\nino-safe.ecf" readonly="false"/>
|
||||||
<library name="connector_libfcgi" location="..\..\connectors\libfcgi\libfcgi-safe.ecf" readonly="false"/>
|
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
|
||||||
<cluster name="src" location="src\" recursive="true"/>
|
<cluster name="src" location="src\" recursive="true"/>
|
||||||
</target>
|
</target>
|
||||||
</system>
|
</system>
|
||||||
|
|||||||
@@ -7,53 +7,23 @@ note
|
|||||||
class
|
class
|
||||||
HELLO_WORLD
|
HELLO_WORLD
|
||||||
|
|
||||||
inherit
|
|
||||||
GW_APPLICATION_IMP
|
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make
|
make
|
||||||
-- Initialize `Current'.
|
|
||||||
local
|
|
||||||
conn: detachable GW_CONNECTOR
|
|
||||||
nino_conn: GW_NINO_CONNECTOR
|
|
||||||
do
|
do
|
||||||
if is_nino then
|
print ("Example: start a Nino web server on port " + port_number.out + ", %Nand reply Hello World for any request such as http://localhost:8123/%N")
|
||||||
create nino_conn.make_with_base (Current, "/hello_world")
|
(create {GW_NINO_APPLICATION}.make (agent (ctx: GW_REQUEST_CONTEXT)
|
||||||
if attached nino_conn.server.server_configuration as cfg then
|
do
|
||||||
cfg.http_server_port := 8080
|
ctx.output.put_header (200, <<["Content-Type", "text/plain"]>>)
|
||||||
cfg.force_single_threaded := True
|
ctx.output.put_string ("Hello World!%N")
|
||||||
end
|
end
|
||||||
conn := nino_conn
|
)).listen (port_number)
|
||||||
elseif is_cgi then
|
|
||||||
create {GW_CGI_CONNECTOR} conn.make (Current)
|
|
||||||
elseif is_libfcgi then
|
|
||||||
create {GW_LIBFCGI_CONNECTOR} conn.make (Current)
|
|
||||||
else
|
|
||||||
io.error.put_string ("Unsupported connector")
|
|
||||||
end
|
|
||||||
if conn /= Void then
|
|
||||||
conn.launch
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
is_nino: BOOLEAN = True
|
port_number: INTEGER = 8123
|
||||||
is_cgi: BOOLEAN = False
|
|
||||||
is_libfcgi: BOOLEAN = False
|
|
||||||
|
|
||||||
feature -- Execution
|
|
||||||
|
|
||||||
execute (ctx: GW_REQUEST_CONTEXT)
|
|
||||||
-- Execute the request
|
|
||||||
do
|
|
||||||
ctx.output.put_string ("Hello World!%N")
|
|
||||||
if attached ctx.execution_variable ("REQUEST_COUNT") as rq_count then
|
|
||||||
ctx.output.put_string ("Request #" + rq_count + "%N")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2011, Eiffel Software and others"
|
copyright: "2011-2011, Eiffel Software and others"
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {GW_AGENT_APPLICATION}."
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
GW_AGENT_APPLICATION
|
||||||
|
|
||||||
|
inherit
|
||||||
|
GW_APPLICATION_IMP
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
|
make (a_callback: like callback)
|
||||||
|
-- Initialize `Current'.
|
||||||
|
do
|
||||||
|
callback := a_callback
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
|
callback: PROCEDURE [ANY, TUPLE [like new_request_context]]
|
||||||
|
-- Procedure called on `execute'
|
||||||
|
|
||||||
|
execute (ctx: like new_request_context)
|
||||||
|
-- Execute the request
|
||||||
|
do
|
||||||
|
callback.call ([ctx])
|
||||||
|
end
|
||||||
|
|
||||||
|
invariant
|
||||||
|
callback_attached: callback /= Void
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2011, 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
|
||||||
Reference in New Issue
Block a user