hueplusplus  1.0.0
BaseHttpHandler.h
Go to the documentation of this file.
1 
23 #ifndef INCLUDE_HUEPLUSPLUS_BASE_HTTP_HANDLER_H
24 #define INCLUDE_HUEPLUSPLUS_BASE_HTTP_HANDLER_H
25 
26 #include <iostream>
27 #include <memory>
28 #include <string>
29 #include <vector>
30 
31 #include "IHttpHandler.h"
32 
33 #include "json/json.hpp"
34 
35 namespace hueplusplus
36 {
39 {
40 public:
42  virtual ~BaseHttpHandler() = default;
43 
52  std::string sendGetHTTPBody(const std::string& msg, const std::string& adr, int port = 80) const override;
53 
65  std::string sendHTTPRequest(const std::string& method, const std::string& uri, const std::string& contentType,
66  const std::string& body, const std::string& adr, int port = 80) const override;
67 
79  std::string GETString(const std::string& uri, const std::string& contentType, const std::string& body,
80  const std::string& adr, int port = 80) const override;
81 
93  std::string POSTString(const std::string& uri, const std::string& contentType, const std::string& body,
94  const std::string& adr, int port = 80) const override;
95 
107  std::string PUTString(const std::string& uri, const std::string& contentType, const std::string& body,
108  const std::string& adr, int port = 80) const override;
109 
121  std::string DELETEString(const std::string& uri, const std::string& contentType, const std::string& body,
122  const std::string& adr, int port = 80) const override;
123 
134  nlohmann::json GETJson(
135  const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override;
136 
147  nlohmann::json POSTJson(
148  const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override;
149 
160  nlohmann::json PUTJson(
161  const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override;
162 
173  nlohmann::json DELETEJson(
174  const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override;
175 };
176 } // namespace hueplusplus
177 
178 #endif
std::string DELETEString(const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const override
Send a HTTP DELETE request to the specified host and return the body of the response.
Definition: BaseHttpHandler.cpp:97
virtual ~BaseHttpHandler()=default
Virtual dtor.
std::string POSTString(const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const override
Send a HTTP POST request to the specified host and return the body of the response.
Definition: BaseHttpHandler.cpp:85
Namespace for the hueplusplus library.
Definition: Action.h:27
nlohmann::json POSTJson(const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const override
Send a HTTP POST request to the specified host and return the body of the response parsed as JSON...
Definition: BaseHttpHandler.cpp:109
Abstract class for classes that handle http requests and multicast requests.
Definition: IHttpHandler.h:37
nlohmann::json GETJson(const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const override
Send a HTTP GET request to the specified host and return the body of the response parsed as JSON...
Definition: BaseHttpHandler.cpp:103
std::string GETString(const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const override
Send a HTTP GET request to the specified host and return the body of the response.
Definition: BaseHttpHandler.cpp:79
nlohmann::json PUTJson(const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const override
Send a HTTP PUT request to the specified host and return the body of the response parsed as JSON...
Definition: BaseHttpHandler.cpp:115
std::string sendHTTPRequest(const std::string &method, const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const override
Send a HTTP request with the given method to the specified host and return the body of the response...
Definition: BaseHttpHandler.cpp:46
std::string sendGetHTTPBody(const std::string &msg, const std::string &adr, int port=80) const override
Send a message to a specified host and return the body of the response.
Definition: BaseHttpHandler.cpp:29
nlohmann::json DELETEJson(const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const override
Send a HTTP DELETE request to the specified host and return the body of the response parsed as JSON...
Definition: BaseHttpHandler.cpp:121
std::string PUTString(const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const override
Send a HTTP PUT request to the specified host and return the body of the response.
Definition: BaseHttpHandler.cpp:91
Base class for classes that handle http requests and multicast requests.
Definition: BaseHttpHandler.h:38