Compare commits

...

2 Commits

6 changed files with 85 additions and 50 deletions

View File

@@ -1,6 +1,5 @@
note
description: "Objects than can pre-process incoming data and post-process outgoing data."
author: "Olivier Ligot"
date: "$Date$"
revision: "$Revision$"
@@ -9,9 +8,23 @@ deferred class
feature -- Access
next: detachable WSF_FILTER
next: detachable WSF_FILTER assign set_next
-- Next filter
last: WSF_FILTER
-- Last filter in the chain following `next'.
do
from
Result := Current
until
not attached Result.next as l_next
loop
Result := l_next
end
ensure
is_closing: Result /= Void and then Result.next = Void
end
feature -- Element change
set_next (a_next: like next)
@@ -22,6 +35,24 @@ feature -- Element change
next_set: next = a_next
end
append (a_filter: attached like next)
-- Append `a_filter' to the `last' filter.
do
last.set_next (a_filter)
end
insert_after (a_filter: attached like next)
-- Append `a_filter' to the `last' filter.
local
f: like next
do
f := next
set_next (a_filter)
if f /= Void then
a_filter.append (f)
end
end
feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)

View File

@@ -29,22 +29,19 @@ feature {NONE} -- Initialization
deferred
end
append_filter (a_filter: WSF_FILTER)
-- Append `a_filter' to the end of the `filter' chain.
do
filter.append (a_filter)
end
append_filters (a_filters: ITERABLE [WSF_FILTER])
-- Append collection `a_filters' of filters to the end of the `filter' chain.
local
f: like filter
l_next_filter: detachable like filter
do
from
f := filter
l_next_filter := f.next
until
l_next_filter = Void
loop
f := l_next_filter
l_next_filter := f.next
end
check f_attached_without_next: f /= Void and then f.next = Void end
f := filter.last
across
a_filters as ic
loop
@@ -59,5 +56,4 @@ feature -- Access
filter: WSF_FILTER
-- Filter
end

View File

@@ -15,10 +15,10 @@
</target>
<target name="{$WIZ.project.name/}_any" extends="common">
<root class="{$APP_ROOT/}" feature="make_and_launch"/>
{if condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"}<library name="standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\standalone-safe.ecf"/>{/if}
{if condition="$WIZ.connectors.use_cgi ~ $WIZ_YES"}<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/>{/if}
{if condition="$WIZ.connectors.use_libfcgi ~ $WIZ_YES"}<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/>{/if}
{if condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"}<library name="standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\standalone-safe.ecf"/>{/if}
<cluster name="launcher" location=".\launcher\" recursive="true">
<cluster name="launcher" location=".\launcher\">
<cluster name="any_launcher" location="$|any"/>
</cluster>
<cluster name="src" location=".\src\" recursive="true"/>

View File

@@ -20,28 +20,27 @@ feature -- Execution
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
-- Launch Web Server Application using optionals `opts'.
local
launcher: WSF_SERVICE_LAUNCHER
launcher: WSF_SERVICE_LAUNCHER [G]
do
l_id := launcher_id
if not attached launcher_id as l_id then
{unless condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"}{literal}
io.error.put_string ("Application launcher not found!%N")
(create {EXCEPTIONS}).die (-1){/literal}{/unless}
{if condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"}{literal}
-- Choose a default -> standalone
create {WSF_STANDALONE_SERVICE_LAUNCHER} launcher.make_and_launch (opts){/literal}{/if}
create {WSF_STANDALONE_SERVICE_LAUNCHER [G]} launcher.make_and_launch (opts){/literal}{/if}
{if condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"}{literal}
elseif is_standalone_launcher_id (l_id) then
create {WSF_STANDALONE_SERVICE_LAUNCHER} launcher.make_and_launch (opts){/literal}{/if}
create {WSF_STANDALONE_SERVICE_LAUNCHER [G]} launcher.make_and_launch (opts){/literal}{/if}
{if condition="$WIZ.connectors.use_libfcgi ~ $WIZ_YES"}{literal}
elseif is_libfcgi_launcher_id (l_id) then
create {WSF_LIBFCGI_SERVICE_LAUNCHER} launcher.make_and_launch (opts){/literal}{/if}
create {WSF_LIBFCGI_SERVICE_LAUNCHER [G]} launcher.make_and_launch (opts){/literal}{/if}
{if condition="$WIZ.connectors.use_cgi ~ $WIZ_YES"}{literal}
elseif is_cgi_launcher_id (l_id) then
create {WSF_CGI_SERVICE_LAUNCHER} launcher.make_and_launch (opts){/literal}{/if}
create {WSF_CGI_SERVICE_LAUNCHER [G]} launcher.make_and_launch (opts){/literal}{/if}
{if condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"}{literal}
elseif is_standalone_launcher_id (l_id) then
create {WSF_STANDALONE_SERVICE_LAUNCHER} launcher.make_and_launch (opts){/literal}{/if}
create {WSF_STANDALONE_SERVICE_LAUNCHER [G]} launcher.make_and_launch (opts){/literal}{/if}
{literal}
else
io.error.put_string ("Application launcher not found!%N")
@@ -53,31 +52,39 @@ feature -- Execution
-- Launcher id based on the executable extension name if any.
-- This can be redefine to customize for your application.
--| ex: standalone, cgi, libfcgi or Void.
local
p: PATH
s: READABLE_STRING_32
do
if attached (create {PATH}.make_from_string (execution_environment.arguments.command_name)).extension as ext then
Result := ext
create p.make_from_string (execution_environment.arguments.command_name)
if attached p.extension as ext then
if ext.is_case_insensitive_equal_general ("exe") then
-- Windows
s := p.name
create p.make_from_string (s.head (s.count - 4))
Result := p.extension
else
Result := ext
end
end
end
feature -- Status report
{/literal}
feature -- Status report{/literal}
{if condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"}
is_standalone_launcher_id (a_id: READABLE_STRING_GENERAL): BOOLEAN
do
Result := a_id.is_case_insensitive ("standalone")
Result := a_id.is_case_insensitive_equal ("standalone")
end{/if}
{if condition="$WIZ.connectors.use_cgi ~ $WIZ_YES"}
is_cgi_launcher_id (a_id: READABLE_STRING_GENERAL): BOOLEAN
do
Result := a_id.is_case_insensitive ("cgi")
Result := a_id.is_case_insensitive_equal ("cgi")
end{/if}
{if condition="$WIZ.connectors.use_libfcgi ~ $WIZ_YES"}
is_libfcgi_launcher_id (a_id: READABLE_STRING_GENERAL): BOOLEAN
do
Result := a_id.is_case_insensitive ("libfcgi")
or a_id.is_case_insensitive ("fcgi")
Result := a_id.is_case_insensitive_equal ("libfcgi")
or a_id.is_case_insensitive_equal ("fcgi")
end{/if}
end

View File

@@ -14,10 +14,8 @@ inherit
redefine
initialize
end
{if condition="$WIZ.routers.use_router ~ $WIZ_YES"}
WSF_ROUTED_SERVICE{/if}
{if isset="$APP_ROOT"}APPLICATION_LAUNCHER [{$APP_ROOT/}_EXECUTION]{/if}
{unless isset="$APP_ROOT"}APPLICATION_LAUNCHER [APPLICATION_EXECUTION]{/if}
{unless isset="$APP_ROOT"}APPLICATION_LAUNCHER [APPLICATION_EXECUTION]{/unless}
{literal}create
make_and_launch
@@ -29,6 +27,7 @@ feature {NONE} -- Initialization
do
Precursor
set_service_option ("port", {$WIZ.standalone_connector.port/})
set_service_option ("verbose", "{$WIZ.standalone_connector.verbose/}")
end

View File

@@ -11,15 +11,15 @@ class
inherit
{unless condition="$WIZ.routers.use_router ~ $WIZ_YES"}
{unless condition="$WIZ.routers.use_filter ~ $WIZ_YES"}
{unless condition="$WIZ.filters.use_filter ~ $WIZ_YES"}
WSF_EXECUTION{/unless}
{if condition="$WIZ.routers.use_filter ~ $WIZ_YES"}
{if condition="$WIZ.filters.use_filter ~ $WIZ_YES"}
WSF_FILTERED_EXECUTION{/if}
{/unless}
{if condition="$WIZ.routers.use_router ~ $WIZ_YES"}
{unless condition="$WIZ.routers.use_filter ~ $WIZ_YES"}
{unless condition="$WIZ.filters.use_filter ~ $WIZ_YES"}
WSF_ROUTED_EXECUTION{/unless}
{if condition="$WIZ.routers.use_filter ~ $WIZ_YES"}
{if condition="$WIZ.filters.use_filter ~ $WIZ_YES"}
WSF_FILTERED_ROUTED_EXECUTION{/if}
{/if}
@@ -28,7 +28,6 @@ inherit
feature {NONE} -- Initialization
{/literal}
{unless condition="$WIZ.routers.use_router ~ $WIZ_YES"}{literal}
feature -- Execution
@@ -42,9 +41,9 @@ feature -- Execution
--| To send back easily a simple plaintext message.
create mesg.make_with_body ("Hello Eiffel Web")
response.send (mesg)
end{/unless}
{if condition="$WIZ.routers.use_filter ~ $WIZ_YES"}{literal}
end
{/literal}{/unless}
{if condition="$WIZ.filters.use_filter ~ $WIZ_YES"}{literal}
feature -- Filter
create_filter
@@ -56,15 +55,18 @@ feature -- Filter
setup_filter
-- Setup `filter'
local
f: like filter
do
append_filters (<<
create {WSF_CORS_FILTER},
create {WSF_LOGGING_FILTER}
>>)
create {WSF_CORS_FILTER} f
f.set_next (create {WSF_LOGGING_FILTER})
--| Chain more filters like {WSF_CUSTOM_HEADER_FILTER}, ...
--| and your owns filters.
end{/if}
filter.append (f)
end
{/literal}{/if}
{if condition="$WIZ.routers.use_router ~ $WIZ_YES"}{literal}
feature -- Router
@@ -78,12 +80,12 @@ feature -- Router
--| /* are dispatched to serve files/directories contained in "www" directory
--| Self documentation
router.handle_with_request_methods ("/doc", create {WSF_ROUTER_SELF_DOCUMENTATION_HANDLER}.make (router), router.methods_GET)
router.handle ("/doc", create {WSF_ROUTER_SELF_DOCUMENTATION_HANDLER}.make (router), router.methods_GET)
--| Files publisher
create fhdl.make_hidden ("www")
fhdl.set_directory_index (<<"index.html">>)
router.handle_with_request_methods ("", fhdl, router.methods_GET)
router.handle ("", fhdl, router.methods_GET)
end{/literal}{/if}
end