Loading...
Searching...
No Matches
IHttpHandler.h
Go to the documentation of this file.
#ifndef INCLUDE_HUEPLUSPLUS_IHTTPHANDLER_H
#define INCLUDE_HUEPLUSPLUS_IHTTPHANDLER_H
#include <chrono>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <nlohmann/json.hpp>
namespace hueplusplus
{
class IHttpHandler
{
public:
virtual ~IHttpHandler() = default;
virtual std::string send(const std::string& msg, const std::string& adr, int port = 80) const = 0;
virtual std::string sendGetHTTPBody(const std::string& msg, const std::string& adr, int port = 80) const = 0;
virtual std::vector<std::string> sendMulticast(const std::string& msg, const std::string& adr = "239.255.255.250",
int port = 1900, std::chrono::steady_clock::duration timeout = std::chrono::seconds(5)) const = 0;
virtual 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 = 0;
virtual std::string GETString(const std::string& uri, const std::string& contentType, const std::string& body,
const std::string& adr, int port = 80) const = 0;
virtual std::string POSTString(const std::string& uri, const std::string& contentType, const std::string& body,
const std::string& adr, int port = 80) const = 0;
virtual std::string PUTString(const std::string& uri, const std::string& contentType, const std::string& body,
const std::string& adr, int port = 80) const = 0;
virtual std::string DELETEString(const std::string& uri, const std::string& contentType, const std::string& body,
const std::string& adr, int port = 80) const = 0;
virtual nlohmann::json GETJson(
const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const = 0;
virtual nlohmann::json POSTJson(
const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const = 0;
virtual nlohmann::json PUTJson(
const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const = 0;
virtual nlohmann::json DELETEJson(
const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const = 0;
};
} // namespace hueplusplus
#endif
hueplusplus::IHttpHandler
Abstract class for classes that handle http requests and multicast requests.
Definition IHttpHandler.h:38
hueplusplus::IHttpHandler::GETString
virtual std::string GETString(const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
Send a HTTP GET request to the specified host and return the body of the response.
hueplusplus::IHttpHandler::POSTString
virtual std::string POSTString(const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
Send a HTTP POST request to the specified host and return the body of the response.
hueplusplus::IHttpHandler::PUTString
virtual std::string PUTString(const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
Send a HTTP PUT request to the specified host and return the body of the response.
hueplusplus::IHttpHandler::sendMulticast
virtual std::vector< std::string > sendMulticast(const std::string &msg, const std::string &adr="239.255.255.250", int port=1900, std::chrono::steady_clock::duration timeout=std::chrono::seconds(5)) const =0
Send a multicast request with a specified message.
hueplusplus::IHttpHandler::DELETEString
virtual std::string DELETEString(const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
Send a HTTP DELETE request to the specified host and return the body of the response.
hueplusplus::IHttpHandler::DELETEJson
virtual nlohmann::json DELETEJson(const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const =0
Send a HTTP DELETE request to the specified host and return the body of the response parsed as JSON.
hueplusplus::IHttpHandler::sendGetHTTPBody
virtual std::string sendGetHTTPBody(const std::string &msg, const std::string &adr, int port=80) const =0
Send a message to a specified host and return the body of the response.
hueplusplus::IHttpHandler::GETJson
virtual nlohmann::json GETJson(const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const =0
Send a HTTP GET request to the specified host and return the body of the response parsed as JSON.
hueplusplus::IHttpHandler::PUTJson
virtual nlohmann::json PUTJson(const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const =0
Send a HTTP PUT request to the specified host and return the body of the response parsed as JSON.
hueplusplus::IHttpHandler::send
virtual std::string send(const std::string &msg, const std::string &adr, int port=80) const =0
Send a message to a specified host and return the response.
hueplusplus::IHttpHandler::sendHTTPRequest
virtual 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 =0
Send a HTTP request with the given method to the specified host and return the body of the response.
hueplusplus::IHttpHandler::~IHttpHandler
virtual ~IHttpHandler()=default
Virtual dtor.
hueplusplus::IHttpHandler::POSTJson
virtual nlohmann::json POSTJson(const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const =0
Send a HTTP POST request to the specified host and return the body of the response parsed as JSON.
hueplusplus
Namespace for the hueplusplus library.
Definition Action.h:28