Files
ROC/examples/roc_api/modules/demo/cms_demo_module.e
Jocelyn Fiat 241b003542 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.
2014-11-10 14:59:17 +01:00

97 lines
2.5 KiB
Plaintext

note
description: "Summary description for {CMS_DEMO_MODULE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_DEMO_MODULE
inherit
CMS_MODULE
create
make
feature {NONE} -- Initialization
make
do
name := "Demo module"
version := "1.0"
description := "Service to demonstrate and test cms system"
package := "demo"
end
feature -- Access: router
router (a_api: CMS_API): WSF_ROUTER
-- Node router.
do
create Result.make (2)
map_uri_template_agent (Result, "/demo/", agent handle_demo)
map_uri_template_agent (Result, "/book/{id}", agent handle_demo_entry)
end
feature -- Handler
handle_demo,
handle_demo_entry (req: WSF_REQUEST; res: WSF_RESPONSE)
local
m: WSF_NOT_FOUND_RESPONSE
do
create m.make (req)
m.set_body ("Not yet implemented!")
res.send (m)
end
feature -- Mapping helper: uri template
map_uri_template (a_router: WSF_ROUTER; a_tpl: STRING; h: WSF_URI_TEMPLATE_HANDLER)
-- Map `h' as handler for `a_tpl'
require
a_tpl_attached: a_tpl /= Void
h_attached: h /= Void
do
map_uri_template_with_request_methods (a_router, a_tpl, h, Void)
end
map_uri_template_with_request_methods (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS)
-- Map `h' as handler for `a_tpl' for request methods `rqst_methods'.
require
a_tpl_attached: a_tpl /= Void
h_attached: h /= Void
do
a_router.map_with_request_methods (create {WSF_URI_TEMPLATE_MAPPING}.make (a_tpl, h), rqst_methods)
end
feature -- Mapping helper: uri template agent
map_uri_template_agent (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]])
-- Map `proc' as handler for `a_tpl'
require
a_tpl_attached: a_tpl /= Void
proc_attached: proc /= Void
do
map_uri_template_agent_with_request_methods (a_router, a_tpl, proc, Void)
end
map_uri_template_agent_with_request_methods (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
-- Map `proc' as handler for `a_tpl' for request methods `rqst_methods'.
require
a_tpl_attached: a_tpl /= Void
proc_attached: proc /= Void
do
map_uri_template_with_request_methods (a_router, a_tpl, create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (proc), rqst_methods)
end
feature -- Hooks
register_hooks (a_response: CMS_RESPONSE)
do
end
end