Third iteration of contracts for non-Void-safe users

This commit is contained in:
Colin Adams
2013-03-15 10:16:32 +00:00
parent 049f769638
commit c6d022bf18
4 changed files with 37 additions and 2 deletions

View File

@@ -15,6 +15,10 @@ inherit
feature -- Execution feature -- Execution
execute (req: WSF_REQUEST; res: WSF_RESPONSE) execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute `req' responding in `res'.
require
req_attached: req /= Void
res_attached: res /= Void
deferred deferred
end end

View File

@@ -21,17 +21,25 @@ feature -- Access
feature -- Change feature -- Change
set_handler (h: like handler) set_handler (h: like handler)
-- <Precursor>
do do
handler := h handler := h
ensure then
h_aliased: handler = h
end end
feature {NONE} -- Execution feature {NONE} -- Execution
execute_handler (h: like handler; req: WSF_REQUEST; res: WSF_RESPONSE) execute_handler (h: like handler; req: WSF_REQUEST; res: WSF_RESPONSE)
-- <Precursor>
do do
h.execute (req, res) h.execute (req, res)
end end
invariant
handler_attached: handler /= Void
note note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -15,20 +15,27 @@ inherit
feature {NONE} -- Initialization feature {NONE} -- Initialization
make (s: READABLE_STRING_8; h: like handler) make (s: READABLE_STRING_8; h: like handler)
-- <Precursor>
do do
make_from_template (create {URI_TEMPLATE}.make (s), h) make_from_template (create {URI_TEMPLATE}.make (s), h)
end end
make_from_template (tpl: URI_TEMPLATE; h: like handler) make_from_template (tpl: URI_TEMPLATE; h: like handler)
-- Create with `h' as the handler for resources matching `tpl'
require
tpl_attached: tpl /= Void
h_attached: h /= Void
do do
template := tpl template := tpl
set_handler (h) set_handler (h)
ensure
tpl_aliased: template = tpl
end end
feature -- Access feature -- Access
associated_resource: READABLE_STRING_8 associated_resource: READABLE_STRING_8
-- Associated resource -- URI template text of handled resource
do do
Result := template.template Result := template.template
end end
@@ -38,6 +45,9 @@ feature -- Access
feature -- Change feature -- Change
set_handler (h: like handler) set_handler (h: like handler)
-- Set `handler' to `h'.
require
h_attached: h /= Void
deferred deferred
end end
@@ -59,6 +69,7 @@ feature -- Status
end end
routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER
-- <Precursor>
local local
tpl: URI_TEMPLATE tpl: URI_TEMPLATE
p: READABLE_STRING_32 p: READABLE_STRING_32
@@ -88,13 +99,21 @@ feature -- Status
feature {NONE} -- Execution feature {NONE} -- Execution
execute_handler (h: like handler; req: WSF_REQUEST; res: WSF_RESPONSE) execute_handler (h: like handler; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute handler `h' with `req' and `res' for Current mapping -- Run `h' to execute `req' responding in `res'.
require
h_attached: h /= Void
req_attached: req /= Void
res_attached: res /= Void
deferred deferred
end end
feature {NONE} -- Implementation feature {NONE} -- Implementation
based_uri_template (a_tpl: like template; a_router: WSF_ROUTER): like template based_uri_template (a_tpl: like template; a_router: WSF_ROUTER): like template
-- Version of `a_tpl' using bas URI of `a_router'
require
a_tpl_attached: a_tpl /= Void
a_router_attached: a_router /= Void
do do
if attached a_router.base_url as l_base_url then if attached a_router.base_url as l_base_url then
Result := a_tpl.duplicate Result := a_tpl.duplicate
@@ -102,6 +121,8 @@ feature {NONE} -- Implementation
else else
Result := a_tpl Result := a_tpl
end end
ensure
based_uri_template_attached: Result /= Void
end end
note note

View File

@@ -14,6 +14,8 @@ feature {WSF_ROUTER} -- Mapping
new_mapping (a_uri: READABLE_STRING_8): WSF_ROUTER_MAPPING new_mapping (a_uri: READABLE_STRING_8): WSF_ROUTER_MAPPING
-- New mapping object -- New mapping object
require
a_uri_attached: a_uri /= Void
deferred deferred
ensure ensure
Result_attached: Result /= Void Result_attached: Result /= Void