Fixed various compilation issue with new self documentation

Improved the self documentation handler to provide a make_hidden creation procedure
This commit is contained in:
Jocelyn Fiat
2012-12-03 12:20:12 +01:00
parent e0166a4c44
commit 156406f9ac
6 changed files with 40 additions and 3 deletions

View File

@@ -10,6 +10,9 @@ inherit
ANY
WSF_URI_TEMPLATE_ROUTED_SERVICE
redefine
execute_default
end
WSF_HANDLER_HELPER
@@ -30,10 +33,13 @@ feature {NONE} -- Initialization
setup_router
local
order_handler: ORDER_HANDLER
doc: WSF_ROUTER_SELF_DOCUMENTATION_HANDLER
do
create order_handler
router.handle_with_request_methods ("/order", order_handler, router.methods_POST)
router.handle_with_request_methods ("/order/{orderid}", order_handler, router.methods_GET + router.methods_DELETE + router.methods_PUT)
create doc.make_hidden (router)
router.handle_with_request_methods ("/api/doc", doc, router.methods_GET)
end
feature -- Execution
@@ -54,6 +60,7 @@ feature -- Execution
h.put_content_type_text_plain
l_api_doc := "%NPlease check the API%NURI:/order METHOD: POST%NURI:/order/{orderid} METHOD: GET, PUT, DELETE%N"
l_description := req.request_method + req.request_uri + " is not allowed" + "%N" + l_api_doc
l_description.append ("%NHTML documentation:/api/doc METHOD: GET%N")
h.put_content_length (l_description.count)
h.put_current_date
res.set_status_code ({HTTP_STATUS_CODE}.method_not_allowed)

View File

@@ -25,7 +25,7 @@ feature -- Status report
debug_output: STRING
-- String that should be displayed in debugger to represent `Current'.
do
Result := Precursor + " {" + {C}.name + "}"
Result := Precursor + " {" + ({C}).name + "}"
end
note

View File

@@ -17,8 +17,11 @@ inherit
on_mapped
end
WSF_SELF_DOCUMENTED_HANDLER
create
make
make,
make_hidden
feature {NONE} -- Initialization
@@ -27,10 +30,28 @@ feature {NONE} -- Initialization
router := a_router
end
make_hidden (a_router: WSF_ROUTER)
do
make (a_router)
is_hidden := True
end
router: WSF_ROUTER
resource: detachable STRING
is_hidden: BOOLEAN
-- Current mapped handler should be hidden from self documentation
feature -- Documentation
mapping_documentation (m: WSF_ROUTER_MAPPING): WSF_ROUTER_MAPPING_DOCUMENTATION
do
create Result.make (m)
Result.set_is_hidden (is_hidden)
Result.add_description ("Self generated documentation based on the router's setup")
end
feature {WSF_ROUTER} -- Mapping
on_mapped (a_mapping: WSF_ROUTER_MAPPING; a_rqst_methods: detachable WSF_ROUTER_METHODS)

View File

@@ -10,6 +10,8 @@ class
inherit
WSF_ROUTER_MAPPING
WSF_SELF_DOCUMENTED_ROUTER_MAPPING
create
make

View File

@@ -11,6 +11,9 @@ inherit
WSF_ROUTER_CONTEXT_MAPPING [C]
WSF_SELF_DOCUMENTED_ROUTER_MAPPING
undefine
debug_output
end
create
make,

View File

@@ -47,7 +47,11 @@ feature -- Execution
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Default procedure
deferred
local
not_found: WSF_NOT_FOUND_RESPONSE
do
create not_found.make (req)
res.send (not_found)
end
feature -- Access