Added DEFAULT_SERVICE_LAUNCHER.make_and_launch_with_options
Added WSF_RESPONSE.redirect_now_with_content (...) Updated hello_routed_world .. mainly example use to test/develop... not really a nice example
This commit is contained in:
@@ -37,6 +37,11 @@ feature {NONE} -- Initialization
|
||||
cgi.launch
|
||||
end
|
||||
|
||||
make_and_launch_with_options (a_action: like action; a_options: ARRAY [detachable TUPLE [name: READABLE_STRING_GENERAL; value: detachable ANY]])
|
||||
do
|
||||
make_and_launch (a_action)
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
action: PROCEDURE [ANY, TUPLE [WSF_REQUEST, WSF_RESPONSE]]
|
||||
|
||||
@@ -37,6 +37,11 @@ feature {NONE} -- Initialization
|
||||
conn.launch
|
||||
end
|
||||
|
||||
make_and_launch_with_options (a_action: like action; a_options: ARRAY [detachable TUPLE [name: READABLE_STRING_GENERAL; value: detachable ANY]])
|
||||
do
|
||||
make_and_launch (a_action)
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
action: PROCEDURE [ANY, TUPLE [WSF_REQUEST, WSF_RESPONSE]]
|
||||
|
||||
@@ -13,6 +13,15 @@ note
|
||||
do
|
||||
-- ...
|
||||
end
|
||||
|
||||
You can also provide specific options that might be relevant
|
||||
only for specific connectors such as
|
||||
|
||||
create s.make_and_launch_and_options (agent execute, <<["port", 8099]>>)
|
||||
The Nino default connector support:
|
||||
port: numeric such as 8099 (or equivalent string as "8099")
|
||||
base: base_url (very specific to standalone server)
|
||||
verbose: to display verbose output, useful for Nino
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -24,28 +33,73 @@ inherit
|
||||
WSF_SERVICE
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
make_and_launch,
|
||||
make_and_launch_with_options
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_and_launch (a_action: like action)
|
||||
local
|
||||
app: NINO_SERVICE
|
||||
port_number: INTEGER
|
||||
base_url: STRING
|
||||
do
|
||||
action := a_action
|
||||
port_number := 8087 --| Default, but quite often, this port is already used ...
|
||||
launch (80, "", False)
|
||||
end
|
||||
|
||||
make_and_launch_with_options (a_action: like action; a_options: ARRAY [detachable TUPLE [name: READABLE_STRING_GENERAL; value: detachable ANY]])
|
||||
local
|
||||
port_number: INTEGER
|
||||
base_url: STRING
|
||||
verbose: BOOLEAN
|
||||
l_name: READABLE_STRING_GENERAL
|
||||
do
|
||||
action := a_action
|
||||
port_number := 80 --| Default, but quite often, this port is already used ...
|
||||
base_url := ""
|
||||
debug ("nino")
|
||||
print ("Example: start a Nino web server on port " + port_number.out +
|
||||
", %Nand reply Hello World for any request such as http://localhost:" + port_number.out + "/" + base_url + "%N")
|
||||
across
|
||||
a_options as opt
|
||||
loop
|
||||
if attached opt.item as l_opt_item then
|
||||
l_name := l_opt_item.name
|
||||
if l_name.same_string ("port") then
|
||||
if attached {INTEGER} l_opt_item.value as l_port then
|
||||
port_number := l_port
|
||||
elseif
|
||||
attached {READABLE_STRING_GENERAL} l_opt_item.value as l_port_str and then
|
||||
l_port_str.is_integer
|
||||
then
|
||||
port_number := l_port_str.as_string_8.to_integer
|
||||
end
|
||||
elseif l_name.same_string ("base") then
|
||||
if attached {READABLE_STRING_GENERAL} l_opt_item.value as l_base_str then
|
||||
base_url := l_base_str.as_string_8
|
||||
end
|
||||
elseif l_name.same_string ("verbose") then
|
||||
if attached {BOOLEAN} l_opt_item.value as l_verbose then
|
||||
verbose := l_verbose
|
||||
elseif attached {READABLE_STRING_GENERAL} l_opt_item.value as l_verbose_str then
|
||||
verbose := l_verbose_str.as_lower.same_string ("true")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
create app.make_custom (agent wgi_execute, base_url)
|
||||
launch (port_number, base_url, verbose)
|
||||
end
|
||||
|
||||
launch (a_port: INTEGER; a_base: STRING; a_verbose: BOOLEAN)
|
||||
-- Launch service with `a_port', `a_base' and `a_verbose' value
|
||||
require
|
||||
a_port_valid: a_port > 0
|
||||
local
|
||||
app: NINO_SERVICE
|
||||
do
|
||||
create app.make_custom (agent wgi_execute, a_base)
|
||||
app.set_is_verbose (a_verbose)
|
||||
debug ("nino")
|
||||
app.set_is_verbose (True)
|
||||
if a_verbose then
|
||||
print ("Example: start a Nino web server on port " + a_port.out +
|
||||
", %Nand reply Hello World for any request such as http://localhost:" + a_port.out + "/" + a_base + "%N")
|
||||
end
|
||||
end
|
||||
app.listen (port_number)
|
||||
app.listen (a_port)
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
Reference in New Issue
Block a user