Merge branch 'master' into skeleton_router

This commit is contained in:
Colin Adams
2013-03-22 14:28:01 +00:00
16 changed files with 153 additions and 28 deletions

View File

@@ -158,10 +158,18 @@ feature {WSF_RESPONSE} -- Output
if doc_url_supported then
l_description.append ("<a href=%""+ doc_url ("") + "%">Index</a><br/>")
end
if attached router.item_associated_with_resource (l_api_resource, Void) as l_api_item then
l_description.append ("<h2>Information related to <code>" + l_api_resource + "</code></h2><ul class=%"mapping%">")
append_documentation_to (l_description, l_api_item.mapping, l_api_item.request_methods)
l_description.append ("</ul>")
if
attached router.items_associated_with_resource (l_api_resource, Void) as l_api_items and then
not l_api_items.is_empty
then
l_description.append ("<h2>Information related to <code>" + l_api_resource + "</code></h2>")
across
l_api_items as c
loop
l_description.append ("<ul class=%"mapping%">")
append_documentation_to (l_description, c.item.mapping, c.item.request_methods)
l_description.append ("</ul>")
end
end
else
l_description.append ("<h2>Router</h2><ul class=%"mapping%">")
@@ -304,4 +312,14 @@ feature {NONE} -- Implementation
create Result
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -14,10 +14,19 @@ feature -- Documentation
--| `m' and `a_request_methods' are useful to produce specific documentation when the handler is used for multiple mapping.
require
m_attached: m /= Void
a_request_methods_attached: a_request_methods /= Void
deferred
ensure
mapping_documentation_attached: Result /= Void
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -59,7 +59,7 @@ feature -- Status
end
try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER)
-- Return the handler if Current matches the request `req'.
-- <Precursor>
local
p: READABLE_STRING_8
s: like based_uri

View File

@@ -73,6 +73,7 @@ feature -- Status
end
try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER)
-- <Precursor>
do
if is_mapping (req, a_router) then
sess.set_dispatched_handler (handler)

View File

@@ -228,7 +228,7 @@ feature -- Status report
end
item_associated_with_resource (a_resource: READABLE_STRING_8; rqst_methods: detachable WSF_REQUEST_METHODS): detachable WSF_ROUTER_ITEM
-- Handler and request methods for `a_resource', taking into account `rqst_methods'
-- First handler for `a_resource', taking into account `rqst_methods'
require
a_resource_attached: a_resource /= Void
local
@@ -259,6 +259,37 @@ feature -- Status report
end
end
items_associated_with_resource (a_resource: READABLE_STRING_8; rqst_methods: detachable WSF_REQUEST_METHODS): LIST [WSF_ROUTER_ITEM]
-- All handlers for `a_resource', taking into account `rqst_methods'
require
a_resource_attached: a_resource /= Void
local
m: WSF_ROUTER_MAPPING
ok: BOOLEAN
do
create {ARRAYED_LIST [WSF_ROUTER_ITEM]} Result.make (1)
across
mappings as c
loop
m := c.item.mapping
ok := True
if rqst_methods /= Void then
if attached c.item.request_methods as l_item_rqst_methods then
ok := across rqst_methods as mtd some is_matching_request_methods (mtd.item, l_item_rqst_methods) end
else
ok := True
end
end
if ok then
if attached {WSF_ROUTING_HANDLER} m.handler as l_routing then
Result.append (l_routing.router.items_associated_with_resource (a_resource, rqst_methods))
elseif m.associated_resource.same_string (a_resource) then
Result.force (c.item)
end
end
end
end
allowed_methods_for_request (req: WSF_REQUEST): WSF_REQUEST_METHODS
-- Allowed methods for `req'
require

View File

@@ -24,14 +24,14 @@ feature {NONE} -- Initialization
feature -- Access
associated_resource: READABLE_STRING_8
-- Name (URI, or URI template or regular expression or ...) of handled resource.
-- Name (URI, or URI template or regular expression or ...) of handled resource
deferred
ensure
assciated_resource_not_void: Result /= Void
end
handler: WSF_HANDLER
-- Handler associated with `Current' mapping.
-- Handler associated with `Current' mapping
deferred
ensure
handler_attached: Result /= Void
@@ -40,7 +40,7 @@ feature -- Access
feature -- Documentation
description: READABLE_STRING_32
-- Short description of associated mapping.
-- Short description of associated mapping
deferred
ensure
description_attached: Result /= Void
@@ -78,7 +78,7 @@ feature -- Status
feature -- Helper
path_from_request (req: WSF_REQUEST): READABLE_STRING_32
-- Path used by `Current' to check that mapping matches request `req'.
-- Path used by `Current' to check that mapping matches request `req'
require
req_attached: req /= Void
do