Renamed CMS_API_SERVICE as CMS_API .

Reversed the design, and break dependency CMS_SETUP => CMS_API .
Now CMS_API has attribute setup: CMS_SETUP .
Moved error_handler from CMS_SETUP to CMS_API.
The instance of CMS_SETUP is used when instanciating modules.
The instance of CMS_API is used when instanciating CMS_REPONSE and Handlers/Filters.
The instance of CMS_API is passed as argument to build the CMS_MODULE.router and filter.
This commit is contained in:
2014-11-10 14:59:17 +01:00
parent 730f6d42a4
commit 241b003542
21 changed files with 195 additions and 194 deletions

View File

@@ -20,47 +20,48 @@ create
feature {NONE} -- Initialization
make (a_config: CMS_SETUP)
make (a_setup: CMS_SETUP)
-- Create Current module, disabled by default.
do
name := "node"
version := "1.0"
description := "Service to manage content based on 'node'"
package := "core"
config := a_config
config := a_setup
end
config: CMS_SETUP
-- Node configuration.
feature -- Access: router
router: WSF_ROUTER
router (a_api: CMS_API): WSF_ROUTER
-- Node router.
do
create Result.make (5)
configure_api_node (Result)
configure_api_nodes (Result)
configure_api_node_title (Result)
configure_api_node_summary (Result)
configure_api_node_content (Result)
configure_api_node (a_api, Result)
configure_api_nodes (a_api, Result)
configure_api_node_title (a_api, Result)
configure_api_node_summary (a_api, Result)
configure_api_node_content (a_api, Result)
end
feature {NONE} -- Implementation: routes
configure_api_node (a_router: WSF_ROUTER)
configure_api_node (api: CMS_API; a_router: WSF_ROUTER)
local
l_node_handler: NODE_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_node_handler.make (config)
create l_node_handler.make (api)
create l_methods
l_methods.enable_get
l_methods.enable_post
l_methods.enable_put
a_router.handle_with_request_methods ("/node", l_node_handler, l_methods)
create l_node_handler.make (config)
create l_node_handler.make (api)
create l_methods
l_methods.enable_get
l_methods.enable_post
@@ -69,23 +70,23 @@ feature {NONE} -- Implementation: routes
a_router.handle_with_request_methods ("/node/{id}", l_node_handler, l_methods)
end
configure_api_nodes (a_router: WSF_ROUTER)
configure_api_nodes (api: CMS_API; a_router: WSF_ROUTER)
local
l_nodes_handler: NODES_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_nodes_handler.make (config)
create l_nodes_handler.make (api)
create l_methods
l_methods.enable_get
a_router.handle_with_request_methods ("/nodes", l_nodes_handler, l_methods)
end
configure_api_node_summary (a_router: WSF_ROUTER)
configure_api_node_summary (api: CMS_API; a_router: WSF_ROUTER)
local
l_report_handler: NODE_SUMMARY_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_report_handler.make (config)
create l_report_handler.make (api)
create l_methods
l_methods.enable_get
l_methods.enable_post
@@ -94,12 +95,12 @@ feature {NONE} -- Implementation: routes
end
configure_api_node_title (a_router: WSF_ROUTER)
configure_api_node_title (api: CMS_API; a_router: WSF_ROUTER)
local
l_report_handler: NODE_TITLE_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_report_handler.make (config)
create l_report_handler.make (api)
create l_methods
l_methods.enable_get
l_methods.enable_post
@@ -107,12 +108,12 @@ feature {NONE} -- Implementation: routes
a_router.handle_with_request_methods ("/node/{id}/title", l_report_handler, l_methods)
end
configure_api_node_content (a_router: WSF_ROUTER)
configure_api_node_content (api: CMS_API; a_router: WSF_ROUTER)
local
l_report_handler: NODE_CONTENT_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_report_handler.make (config)
create l_report_handler.make (api)
create l_methods
l_methods.enable_get
l_methods.enable_post
@@ -120,7 +121,6 @@ feature {NONE} -- Implementation: routes
a_router.handle_with_request_methods ("/node/{id}/content", l_report_handler, l_methods)
end
feature -- Hooks
register_hooks (a_response: CMS_RESPONSE)
@@ -150,7 +150,7 @@ feature -- Hooks
menu_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
local
lnk: CMS_LOCAL_LINK
perms: detachable ARRAYED_LIST [READABLE_STRING_8]
-- perms: detachable ARRAYED_LIST [READABLE_STRING_8]
do
create lnk.make ("List of nodes", "/nodes")
a_menu_system.main_menu.extend (lnk)