From 156406f9acda66283cbef47243050ec34cca6642 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Mon, 3 Dec 2012 12:20:12 +0100 Subject: [PATCH] Fixed various compilation issue with new self documentation Improved the self documentation handler to provide a make_hidden creation procedure --- examples/restbucksCRUD/src/restbucks_server.e | 7 ++++++ .../context/wsf_router_context_mapping.e | 2 +- .../wsf_router_self_documentation_handler.e | 23 ++++++++++++++++++- .../starts_with/wsf_starts_with_mapping.e | 2 ++ .../wsf_uri_template_context_mapping.e | 3 +++ .../server/wsf/router/wsf_routed_service.e | 6 ++++- 6 files changed, 40 insertions(+), 3 deletions(-) diff --git a/examples/restbucksCRUD/src/restbucks_server.e b/examples/restbucksCRUD/src/restbucks_server.e index ad1beb4d..79870862 100644 --- a/examples/restbucksCRUD/src/restbucks_server.e +++ b/examples/restbucksCRUD/src/restbucks_server.e @@ -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) diff --git a/library/server/wsf/router/context/wsf_router_context_mapping.e b/library/server/wsf/router/context/wsf_router_context_mapping.e index 92c1f23f..bf7f8895 100644 --- a/library/server/wsf/router/context/wsf_router_context_mapping.e +++ b/library/server/wsf/router/context/wsf_router_context_mapping.e @@ -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 diff --git a/library/server/wsf/router/documentation/wsf_router_self_documentation_handler.e b/library/server/wsf/router/documentation/wsf_router_self_documentation_handler.e index 427037f0..0de5d36b 100644 --- a/library/server/wsf/router/documentation/wsf_router_self_documentation_handler.e +++ b/library/server/wsf/router/documentation/wsf_router_self_documentation_handler.e @@ -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) diff --git a/library/server/wsf/router/support/starts_with/wsf_starts_with_mapping.e b/library/server/wsf/router/support/starts_with/wsf_starts_with_mapping.e index e62ffb50..c152150e 100644 --- a/library/server/wsf/router/support/starts_with/wsf_starts_with_mapping.e +++ b/library/server/wsf/router/support/starts_with/wsf_starts_with_mapping.e @@ -10,6 +10,8 @@ class inherit WSF_ROUTER_MAPPING + WSF_SELF_DOCUMENTED_ROUTER_MAPPING + create make diff --git a/library/server/wsf/router/support/uri_template_with_context/wsf_uri_template_context_mapping.e b/library/server/wsf/router/support/uri_template_with_context/wsf_uri_template_context_mapping.e index fe2b56ca..98f27adf 100644 --- a/library/server/wsf/router/support/uri_template_with_context/wsf_uri_template_context_mapping.e +++ b/library/server/wsf/router/support/uri_template_with_context/wsf_uri_template_context_mapping.e @@ -11,6 +11,9 @@ inherit WSF_ROUTER_CONTEXT_MAPPING [C] WSF_SELF_DOCUMENTED_ROUTER_MAPPING + undefine + debug_output + end create make, diff --git a/library/server/wsf/router/wsf_routed_service.e b/library/server/wsf/router/wsf_routed_service.e index a2a83d8f..00dd52ab 100644 --- a/library/server/wsf/router/wsf_routed_service.e +++ b/library/server/wsf/router/wsf_routed_service.e @@ -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