Kea  1.5.0
post_request_json.h
Go to the documentation of this file.
1 // Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef HTTP_POST_REQUEST_JSON_H
8 #define HTTP_POST_REQUEST_JSON_H
9 
10 #include <cc/data.h>
11 #include <exceptions/exceptions.h>
12 #include <http/post_request.h>
13 #include <boost/shared_ptr.hpp>
14 #include <string>
15 
16 namespace isc {
17 namespace http {
18 
21 public:
22  HttpRequestJsonError(const char* file, size_t line, const char* what) :
23  HttpRequestError(file, line, what) { };
24 };
25 
27 
29 typedef boost::shared_ptr<PostHttpRequestJson> PostHttpRequestJsonPtr;
31 typedef boost::shared_ptr<const PostHttpRequestJson> ConstPostHttpRequestJsonPtr;
32 
40 public:
41 
43  explicit PostHttpRequestJson();
44 
53  explicit PostHttpRequestJson(const Method& method, const std::string& uri,
54  const HttpVersion& version);
55 
60  virtual void finalize();
61 
63  virtual void reset();
64 
70 
79  void setBodyAsJson(const data::ConstElementPtr& body);
80 
90  data::ConstElementPtr getJsonElement(const std::string& element_name) const;
91 
92 protected:
93 
96  void parseBodyAsJson();
97 
100 
101 };
102 
103 } // namespace http
104 } // namespace isc
105 
106 #endif
Represents HTTP POST request with JSON body.
data::ConstElementPtr getJsonElement(const std::string &element_name) const
Retrieves a single JSON element.
Generic exception thrown by HttpRequest class.
Definition: request.h:19
virtual void finalize()
Complete parsing of the HTTP request.
HTTP protocol version.
Definition: http_types.h:14
Represents HTTP POST request.
Definition: post_request.h:29
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
data::ConstElementPtr getBodyAsJson() const
Retrieves JSON body.
Exception thrown when body of the HTTP message is not JSON.
boost::shared_ptr< PostHttpRequestJson > PostHttpRequestJsonPtr
Pointer to PostHttpRequestJson.
virtual void reset()
Reset the state of the object.
PostHttpRequestJson()
Constructor for inbound HTTP request.
HttpRequestJsonError(const char *file, size_t line, const char *what)
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
Method
HTTP methods.
Definition: request.h:52
Defines the logger used by the top-level component of kea-dhcp-ddns.
void setBodyAsJson(const data::ConstElementPtr &body)
Sets JSON body for an outbound message.
data::ConstElementPtr json_
Pointer to the parsed JSON body.
boost::shared_ptr< const PostHttpRequestJson > ConstPostHttpRequestJsonPtr
Pointer to const PostHttpRequestJson.
int version()
returns Kea hooks version.
void parseBodyAsJson()
Interprets body as JSON, which can be later retrieved using data element objects.