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:
@@ -10,6 +10,9 @@ inherit
|
|||||||
ANY
|
ANY
|
||||||
|
|
||||||
WSF_URI_TEMPLATE_ROUTED_SERVICE
|
WSF_URI_TEMPLATE_ROUTED_SERVICE
|
||||||
|
redefine
|
||||||
|
execute_default
|
||||||
|
end
|
||||||
|
|
||||||
WSF_HANDLER_HELPER
|
WSF_HANDLER_HELPER
|
||||||
|
|
||||||
@@ -30,10 +33,13 @@ feature {NONE} -- Initialization
|
|||||||
setup_router
|
setup_router
|
||||||
local
|
local
|
||||||
order_handler: ORDER_HANDLER
|
order_handler: ORDER_HANDLER
|
||||||
|
doc: WSF_ROUTER_SELF_DOCUMENTATION_HANDLER
|
||||||
do
|
do
|
||||||
create order_handler
|
create order_handler
|
||||||
router.handle_with_request_methods ("/order", order_handler, router.methods_POST)
|
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)
|
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
|
end
|
||||||
|
|
||||||
feature -- Execution
|
feature -- Execution
|
||||||
@@ -54,6 +60,7 @@ feature -- Execution
|
|||||||
h.put_content_type_text_plain
|
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_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 := 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_content_length (l_description.count)
|
||||||
h.put_current_date
|
h.put_current_date
|
||||||
res.set_status_code ({HTTP_STATUS_CODE}.method_not_allowed)
|
res.set_status_code ({HTTP_STATUS_CODE}.method_not_allowed)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ feature -- Status report
|
|||||||
debug_output: STRING
|
debug_output: STRING
|
||||||
-- String that should be displayed in debugger to represent `Current'.
|
-- String that should be displayed in debugger to represent `Current'.
|
||||||
do
|
do
|
||||||
Result := Precursor + " {" + {C}.name + "}"
|
Result := Precursor + " {" + ({C}).name + "}"
|
||||||
end
|
end
|
||||||
|
|
||||||
note
|
note
|
||||||
|
|||||||
@@ -17,8 +17,11 @@ inherit
|
|||||||
on_mapped
|
on_mapped
|
||||||
end
|
end
|
||||||
|
|
||||||
|
WSF_SELF_DOCUMENTED_HANDLER
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make,
|
||||||
|
make_hidden
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
@@ -27,10 +30,28 @@ feature {NONE} -- Initialization
|
|||||||
router := a_router
|
router := a_router
|
||||||
end
|
end
|
||||||
|
|
||||||
|
make_hidden (a_router: WSF_ROUTER)
|
||||||
|
do
|
||||||
|
make (a_router)
|
||||||
|
is_hidden := True
|
||||||
|
end
|
||||||
|
|
||||||
router: WSF_ROUTER
|
router: WSF_ROUTER
|
||||||
|
|
||||||
resource: detachable STRING
|
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
|
feature {WSF_ROUTER} -- Mapping
|
||||||
|
|
||||||
on_mapped (a_mapping: WSF_ROUTER_MAPPING; a_rqst_methods: detachable WSF_ROUTER_METHODS)
|
on_mapped (a_mapping: WSF_ROUTER_MAPPING; a_rqst_methods: detachable WSF_ROUTER_METHODS)
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ class
|
|||||||
inherit
|
inherit
|
||||||
WSF_ROUTER_MAPPING
|
WSF_ROUTER_MAPPING
|
||||||
|
|
||||||
|
WSF_SELF_DOCUMENTED_ROUTER_MAPPING
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ inherit
|
|||||||
WSF_ROUTER_CONTEXT_MAPPING [C]
|
WSF_ROUTER_CONTEXT_MAPPING [C]
|
||||||
|
|
||||||
WSF_SELF_DOCUMENTED_ROUTER_MAPPING
|
WSF_SELF_DOCUMENTED_ROUTER_MAPPING
|
||||||
|
undefine
|
||||||
|
debug_output
|
||||||
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
make,
|
make,
|
||||||
|
|||||||
@@ -47,7 +47,11 @@ feature -- Execution
|
|||||||
|
|
||||||
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
|
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
-- Default procedure
|
-- Default procedure
|
||||||
deferred
|
local
|
||||||
|
not_found: WSF_NOT_FOUND_RESPONSE
|
||||||
|
do
|
||||||
|
create not_found.make (req)
|
||||||
|
res.send (not_found)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|||||||
Reference in New Issue
Block a user