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

@@ -18,63 +18,58 @@ create
feature {NONE} -- Initialization
make (a_config: CMS_SETUP)
make
do
name := "basic auth"
version := "1.0"
description := "Service to manage basic authentication"
package := "core"
config := a_config
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 (2)
configure_api_login (Result)
configure_api_logoff (Result)
configure_api_login (a_api, Result)
configure_api_logoff (a_api, Result)
end
feature -- Access: filter
filters: detachable LIST [WSF_FILTER]
filters (a_api: CMS_API): detachable LIST [WSF_FILTER]
-- Possibly list of Filter's module.
do
create {ARRAYED_LIST [WSF_FILTER]} Result.make (2)
Result.extend (create {CORS_FILTER})
Result.extend (create {BASIC_AUTH_FILTER}.make (config))
Result.extend (create {BASIC_AUTH_FILTER}.make (a_api))
end
feature {NONE} -- Implementation: routes
configure_api_login (a_router: WSF_ROUTER)
configure_api_login (api: CMS_API; a_router: WSF_ROUTER)
local
l_bal_handler: BASIC_AUTH_LOGIN_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_bal_handler.make (config)
create l_bal_handler.make (api)
create l_methods
l_methods.enable_get
a_router.handle_with_request_methods ("/basic_auth_login", l_bal_handler, l_methods)
end
configure_api_logoff (a_router: WSF_ROUTER)
configure_api_logoff (api: CMS_API; a_router: WSF_ROUTER)
local
l_bal_handler: BASIC_AUTH_LOGOFF_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_bal_handler.make (config)
create l_bal_handler.make (api)
create l_methods
l_methods.enable_get
a_router.handle_with_request_methods ("/basic_auth_logoff", l_bal_handler, l_methods)
end
feature -- Hooks
register_hooks (a_response: CMS_RESPONSE)