Loading...
Searching...
No Matches
BaseHttpHandler.h
Go to the documentation of this file.
#ifndef INCLUDE_HUEPLUSPLUS_BASE_HTTP_HANDLER_H
#define INCLUDE_HUEPLUSPLUS_BASE_HTTP_HANDLER_H
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include "IHttpHandler.h"
#include <nlohmann/json.hpp>
namespace hueplusplus
{
class BaseHttpHandler : public IHttpHandler
{
public:
virtual ~BaseHttpHandler() = default;
std::string sendGetHTTPBody(const std::string& msg, const std::string& adr, int port = 80) const override;
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;
std::string GETString(const std::string& uri, const std::string& contentType, const std::string& body,
const std::string& adr, int port = 80) const override;
std::string POSTString(const std::string& uri, const std::string& contentType, const std::string& body,
const std::string& adr, int port = 80) const override;
std::string PUTString(const std::string& uri, const std::string& contentType, const std::string& body,
const std::string& adr, int port = 80) const override;
std::string DELETEString(const std::string& uri, const std::string& contentType, const std::string& body,
const std::string& adr, int port = 80) const override;
nlohmann::json GETJson(
const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override;
nlohmann::json POSTJson(
const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override;
nlohmann::json PUTJson(
const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override;
nlohmann::json DELETEJson(
const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override;
};
} // namespace hueplusplus
#endif
IHttpHandler.h
hueplusplus::BaseHttpHandler
Base class for classes that handle http requests and multicast requests.
Definition BaseHttpHandler.h:39
hueplusplus::BaseHttpHandler::GETJson
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
hueplusplus::BaseHttpHandler::~BaseHttpHandler
virtual ~BaseHttpHandler()=default
Virtual dtor.
hueplusplus::BaseHttpHandler::DELETEString
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
hueplusplus::BaseHttpHandler::GETString
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
hueplusplus::BaseHttpHandler::PUTJson
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
hueplusplus::BaseHttpHandler::PUTString
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
hueplusplus::BaseHttpHandler::POSTString
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
hueplusplus::BaseHttpHandler::sendHTTPRequest
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
hueplusplus::BaseHttpHandler::DELETEJson
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
hueplusplus::BaseHttpHandler::POSTJson
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
hueplusplus::BaseHttpHandler::sendGetHTTPBody
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
hueplusplus::IHttpHandler
Abstract class for classes that handle http requests and multicast requests.
Definition IHttpHandler.h:38
hueplusplus
Namespace for the hueplusplus library.
Definition Action.h:28