Make a simple hello world based on nino

This commit is contained in:
Jocelyn Fiat
2011-07-13 15:26:21 +02:00
parent bc98c5a317
commit 9d1fb56cc1
4 changed files with 121 additions and 40 deletions

View File

@@ -9,11 +9,10 @@
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
</option>
<setting name="concurrency" value="thread"/>
<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_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"/>
</target>
</system>

View File

@@ -7,53 +7,23 @@ note
class
HELLO_WORLD
inherit
GW_APPLICATION_IMP
create
make
feature {NONE} -- Initialization
make
-- Initialize `Current'.
local
conn: detachable GW_CONNECTOR
nino_conn: GW_NINO_CONNECTOR
do
if is_nino then
create nino_conn.make_with_base (Current, "/hello_world")
if attached nino_conn.server.server_configuration as cfg then
cfg.http_server_port := 8080
cfg.force_single_threaded := True
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 {GW_NINO_APPLICATION}.make (agent (ctx: GW_REQUEST_CONTEXT)
do
ctx.output.put_header (200, <<["Content-Type", "text/plain"]>>)
ctx.output.put_string ("Hello World!%N")
end
conn := nino_conn
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
)).listen (port_number)
end
is_nino: BOOLEAN = True
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
port_number: INTEGER = 8123
note
copyright: "2011-2011, Eiffel Software and others"