Added routing condition mapping.
Added WSF_EXECUTE_HANDLER as common ancestor for handler with `execute (WSF_REQUEST, WSF_RESPONSE) ..` routine. Made more flexible a few routine by accepting ITERABLE instead of ARRAY, and READABLE_STRING_GENERAL when possible.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
note
|
||||
description: "Summary description for {WSF_ROUTING_AGENT_CONDITION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_ROUTING_AGENT_CONDITION
|
||||
|
||||
inherit
|
||||
WSF_ROUTING_CONDITION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (act: like condition)
|
||||
do
|
||||
condition := act
|
||||
end
|
||||
|
||||
condition: FUNCTION [TUPLE [request: WSF_REQUEST], BOOLEAN]
|
||||
|
||||
feature -- Status report
|
||||
|
||||
accepted (req: WSF_REQUEST): BOOLEAN
|
||||
-- Does `req` satisfy Current condition?
|
||||
do
|
||||
Result := condition (req)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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
|
||||
@@ -0,0 +1,44 @@
|
||||
note
|
||||
description: "[
|
||||
Request path info ends with one of the specified extensions.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_ROUTING_EXTENSION_CONDITION
|
||||
|
||||
inherit
|
||||
WSF_ROUTING_CONDITION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Creation
|
||||
|
||||
make (a_extension_list: ITERABLE [READABLE_STRING_GENERAL])
|
||||
do
|
||||
extension_list := a_extension_list
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
extension_list: ITERABLE [READABLE_STRING_GENERAL]
|
||||
|
||||
feature -- Status report
|
||||
|
||||
accepted (req: WSF_REQUEST): BOOLEAN
|
||||
-- Does `req` satisfy Current condition?
|
||||
local
|
||||
l_path: READABLE_STRING_GENERAL
|
||||
i: INTEGER
|
||||
do
|
||||
l_path := req.percent_encoded_path_info
|
||||
i := l_path.last_index_of ('.', l_path.count)
|
||||
if i > 0 then
|
||||
i := i + 1
|
||||
Result := across extension_list as ic some ic.item.same_caseless_characters (l_path, i, l_path.count, 1) end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,39 @@
|
||||
note
|
||||
description: "[
|
||||
Request path info is associated with existing file.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_ROUTING_FILE_EXISTS_CONDITION
|
||||
|
||||
inherit
|
||||
WSF_ROUTING_PATH_EXISTS_CONDITION
|
||||
redefine
|
||||
path_exists
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Status report
|
||||
|
||||
path_exists (p: PATH): BOOLEAN
|
||||
local
|
||||
fut: FILE_UTILITIES
|
||||
do
|
||||
Result := fut.file_path_exists (p)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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
|
||||
@@ -0,0 +1,64 @@
|
||||
note
|
||||
description: "[
|
||||
Request path info is associated with existing file or folder.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_ROUTING_PATH_EXISTS_CONDITION
|
||||
|
||||
inherit
|
||||
WSF_ROUTING_CONDITION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Creation
|
||||
|
||||
make (a_parent_location: PATH)
|
||||
do
|
||||
parent_location := a_parent_location
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
parent_location: PATH
|
||||
|
||||
feature -- Status report
|
||||
|
||||
path_exists (p: PATH): BOOLEAN
|
||||
local
|
||||
fut: FILE_UTILITIES
|
||||
do
|
||||
Result := fut.file_path_exists (p) or fut.directory_path_exists (p)
|
||||
end
|
||||
|
||||
accepted (req: WSF_REQUEST): BOOLEAN
|
||||
-- Does `req` satisfy Current condition?
|
||||
local
|
||||
l_path: READABLE_STRING_GENERAL
|
||||
p: PATH
|
||||
fut: FILE_UTILITIES
|
||||
do
|
||||
l_path := req.path_info
|
||||
if not l_path.is_empty then
|
||||
if l_path[1] = '/' then
|
||||
l_path := l_path.substring (2, l_path.count)
|
||||
end
|
||||
p := parent_location.extended (l_path)
|
||||
Result := path_exists (p)
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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