Display suggestion is now configurable.

Commit 665772bda2 forces to display only
suggestion for the request's method (this was not the case before).

This commit allows to configure this behaviour: it keeps the current behaviour
but also allows to use the other behaviour where the suggestion is displayed
for each request method (as it was before).
This commit is contained in:
Olivier Ligot
2013-05-17 15:36:37 +02:00
parent 430b34df4f
commit d8987f8718

View File

@@ -24,6 +24,7 @@ feature {NONE} -- Initialization
do do
router := a_router router := a_router
make (req) make (req)
set_suggestion_only_method (True)
end end
feature -- Access feature -- Access
@@ -36,6 +37,9 @@ feature -- Settings
documentation_included: BOOLEAN documentation_included: BOOLEAN
-- Include self-documentation from `router' in the response? -- Include self-documentation from `router' in the response?
suggestion_only_method: BOOLEAN
-- Display only suggestion for `req' method ?
feature -- Change feature -- Change
set_documentation_included (b: BOOLEAN) set_documentation_included (b: BOOLEAN)
@@ -43,6 +47,14 @@ feature -- Change
documentation_included := b documentation_included := b
end end
set_suggestion_only_method (b: BOOLEAN)
-- Set `suggestion_only_method' to `b'
do
suggestion_only_method := b
ensure
suggestion_only_method_set: suggestion_only_method = b
end
feature {WSF_RESPONSE} -- Output feature {WSF_RESPONSE} -- Output
send_to (res: WSF_RESPONSE) send_to (res: WSF_RESPONSE)
@@ -138,10 +150,14 @@ feature {NONE} -- Implementation
not_found_message (req: WSF_REQUEST): WSF_NOT_FOUND_RESPONSE not_found_message (req: WSF_REQUEST): WSF_NOT_FOUND_RESPONSE
local local
vis: WSF_ROUTER_AGENT_ITERATOR vis: WSF_ROUTER_AGENT_ITERATOR
l_method: detachable READABLE_STRING_8
do do
Result := Precursor (req) Result := Precursor (req)
if documentation_included then if documentation_included then
create vis create vis
if suggestion_only_method then
l_method := req.request_method
end
vis.on_item_actions.extend (agent (i: WSF_ROUTER_ITEM; r: WSF_NOT_FOUND_RESPONSE; m: detachable READABLE_STRING_8) vis.on_item_actions.extend (agent (i: WSF_ROUTER_ITEM; r: WSF_NOT_FOUND_RESPONSE; m: detachable READABLE_STRING_8)
local local
l_is_hidden: BOOLEAN l_is_hidden: BOOLEAN
@@ -174,7 +190,7 @@ feature {NONE} -- Implementation
r.add_suggested_text (s, Void) r.add_suggested_text (s, Void)
end end
end end
end (?, Result, req.request_method)) end (?, Result, l_method))
vis.process_router (router) vis.process_router (router)
end end
end end