7 #ifndef ZEROEQ_HTTP_SERVER_H 8 #define ZEROEQ_HTTP_SERVER_H 11 #include <zeroeq/http/request.h> 12 #include <zeroeq/http/types.h> 14 #include <zeroeq/log.h> 15 #include <zeroeq/receiver.h> 57 ZEROEQHTTP_API
explicit Server(
const URI& uri);
58 ZEROEQHTTP_API
explicit Server(
Receiver& shared);
59 explicit Server(Server& shared)
60 : Server(static_cast<Receiver&>(shared))
63 ZEROEQHTTP_API Server();
78 static std::unique_ptr<Server>
parse(
int argc,
const char*
const* argv);
80 static std::unique_ptr<Server>
parse(
int argc,
const char*
const* argv,
125 bool handle(servus::Serializable&
object)
136 ZEROEQHTTP_API
bool handle(
const std::string& endpoint,
137 servus::Serializable&
object);
140 ZEROEQHTTP_API
bool remove(
const servus::Serializable& object);
143 ZEROEQHTTP_API
bool remove(
const std::string& endpoint);
158 ZEROEQHTTP_API
bool handlePUT(servus::Serializable&
object);
166 ZEROEQHTTP_API
bool handlePUT(
const std::string& endpoint,
167 servus::Serializable&
object);
188 ZEROEQHTTP_API
bool handlePUT(
const std::string& endpoint,
189 const std::string& schema,
202 ZEROEQHTTP_API
bool handlePUT(
const std::string& endpoint,
211 ZEROEQHTTP_API
bool handlePUT(
const std::string& endpoint,
212 const std::string& schema,
226 ZEROEQHTTP_API
bool handleGET(
const servus::Serializable&
object);
234 ZEROEQHTTP_API
bool handleGET(
const std::string& endpoint,
235 const servus::Serializable&
object);
257 bool handleGET(
const std::string& endpoint,
const std::string& schema,
265 std::string
getSchema(
const servus::Serializable&
object)
const;
268 ZEROEQHTTP_API std::string
getSchema(
const std::string& endpoint)
const;
284 std::unique_ptr<Impl> _impl;
287 void addSockets(std::vector<detail::Socket>& entries)
final;
288 bool process(detail::Socket& socket)
final;
Enhances servus::URI to guarantee the existance of a schema and to allow construction of [host][:port...
ZEROEQHTTP_API bool handlePUT(servus::Serializable &object)
Subscribe a serializable object to receive updates from HTTP PUT requests.
ZEROEQHTTP_API const URI & getURI() const
Get the publisher URI.
std::function< bool()> PUTFunc
HTTP PUT callback w/o payload, return reply success.
std::function< std::string()> GETFunc
HTTP GET callback to return JSON reply.
static ZEROEQHTTP_API std::unique_ptr< Server > parse(int argc, const char *const *argv)
Create a new Server when requested.
Method
HTTP method used in a Request.
std::function< bool(const std::string &)> PUTPayloadFunc
HTTP PUT callback w/ JSON payload, return reply success.
ZEROEQHTTP_API std::string getSchema(const servus::Serializable &object) const
bool handle(servus::Serializable &object)
Handle PUT and GET for the given object.
std::function< std::future< Response >(const Request &)> RESTFunc
HTTP REST callback with Request parameter returning a Response future.
HTTP Request with method, path and body.
ZEROEQHTTP_API bool handleGET(const servus::Serializable &object)
Subscribe a serializable object to serve HTTP GET requests.
Serves HTTP GET and PUT requests for servus::Serializable objects.
virtual std::future< Response > respondTo(Request &request) const
Respond to a request.
bool handle(Method method, const std::string &endpoint, RESTFunc func)
Handle a single method on a given endpoint.
Base class for entities receiving data.
Publish-subscribe and request-reply.
ZEROEQHTTP_API ~Server()
Destruct this http server.
Defines export visibility macros for library ZeroEQHTTP.
ZEROEQHTTP_API SocketDescriptor getSocketDescriptor() const
Get the underlying socket descriptor.