20 #include <boost/pointer_cast.hpp>
30 struct CtrlAgentHooks {
32 int hook_index_response_;
36 hook_index_auth_ = HooksManager::registerHook(
"auth");
37 hook_index_response_ = HooksManager::registerHook(
"response");
53 CtrlAgentResponseCreator::createNewHttpRequest()
const {
58 CtrlAgentResponseCreator::
61 HttpResponsePtr response = createStockHttpResponseInternal(request, status_code);
67 CtrlAgentResponseCreator::
74 HttpVersion http_version(request->context()->http_version_major_,
75 request->context()->http_version_minor_);
80 http_version.minor_ = 0;
88 CtrlAgentResponseCreator::
100 boost::shared_ptr<CtrlAgentController> controller =
101 boost::dynamic_pointer_cast<CtrlAgentController>(CtrlAgentController::instance());
107 ctx = cfgmgr->getCtrlAgentCfgContext();
112 http_response = auth->checkAuth(*
this, request);
120 if (HooksManager::calloutsPresent(Hooks.hook_index_auth_)) {
126 callout_handle->setArgument(
"request", request);
127 callout_handle->setArgument(
"response", http_response);
130 HooksManager::callCallouts(Hooks.hook_index_auth_, *callout_handle);
131 callout_handle->getArgument(
"request", request);
132 callout_handle->getArgument(
"response", http_response);
140 return (http_response);
153 return (createStockHttpResponse(request, HttpStatusCode::INTERNAL_SERVER_ERROR));
163 ConstElementPtr response = CtrlAgentCommandMgr::instance().processCommand(command);
166 return (createStockHttpResponse(request, HttpStatusCode::INTERNAL_SERVER_ERROR));
169 http_response = boost::dynamic_pointer_cast<
170 HttpResponseJson>(createStockHttpResponseInternal(request, HttpStatusCode::OK));
172 http_response->finalize();
175 if (HooksManager::calloutsPresent(Hooks.hook_index_response_)) {
181 callout_handle->setArgument(
"request", request);
182 callout_handle->setArgument(
"response", http_response);
185 HooksManager::callCallouts(Hooks.hook_index_response_,
187 callout_handle->getArgument(
"response", http_response);
192 return (http_response);
Represents HTTP POST request with JSON body.
boost::shared_ptr< HttpResponseJson > HttpResponseJsonPtr
Pointer to the HttpResponseJson object.
data::ConstElementPtr getBodyAsJson() const
Retrieves JSON body.
boost::shared_ptr< CtrlAgentCfgMgr > CtrlAgentCfgMgrPtr
Defines a shared pointer to CtrlAgentCfgMgr.
unsigned major_
Major HTTP version.
boost::shared_ptr< CtrlAgentProcess > CtrlAgentProcessPtr
Defines a shared pointer to CtrlAgentProcess.
boost::shared_ptr< PostHttpRequestJson > PostHttpRequestJsonPtr
Pointer to PostHttpRequestJson.
boost::shared_ptr< HttpResponse > HttpResponsePtr
Pointer to the HttpResponse object.
Wrapper class around callout handle which automatically resets handle's state.
boost::shared_ptr< const Element > ConstElementPtr
Represents HTTP response with JSON content.
Defines the logger used by the top-level component of kea-dhcp-ddns.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
boost::shared_ptr< HttpRequest > HttpRequestPtr
Pointer to the HttpRequest object.
boost::shared_ptr< CtrlAgentCfgContext > CtrlAgentCfgContextPtr
Pointer to a configuration context.
void setBodyAsJson(const data::ConstElementPtr &json_body)
Generates JSON content from the data structures represented as data::ConstElementPtr.
boost::shared_ptr< HttpAuthConfig > HttpAuthConfigPtr
Type of shared pointers to HTTP authentication configuration.
HttpStatusCode
HTTP status codes (cf RFC 2068)