62 lines
1015 B
C++
62 lines
1015 B
C++
#ifndef HTTPSERVER_H
|
|
#define HTTPSERVER_H
|
|
|
|
#include "HttpPostData.h"
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
|
|
namespace Http {
|
|
|
|
class HttpServerImpl;
|
|
|
|
class HttpServer
|
|
{
|
|
public:
|
|
struct HttpReply
|
|
{
|
|
struct Status
|
|
{
|
|
enum type
|
|
{
|
|
Ok = 200,
|
|
Created = 201,
|
|
Accepted = 202,
|
|
NoContent = 204,
|
|
MultipleChoices = 300,
|
|
MovedPermanently = 301,
|
|
MovedTemporarily = 302,
|
|
NotModified = 304,
|
|
BadRequest = 400,
|
|
Unauthorized = 401,
|
|
Forbidden = 403,
|
|
NotFound = 404,
|
|
InternalServerError = 500,
|
|
NotImplemented = 501,
|
|
BadGateway = 502,
|
|
ServiceUnavailable = 503
|
|
};
|
|
};
|
|
|
|
Status::type status;
|
|
std::string content;
|
|
};
|
|
|
|
public:
|
|
typedef std::function<HttpReply(const std::string&, const std::vector<HttpPostData>&)> CallbackMethod;
|
|
|
|
public:
|
|
HttpServer(unsigned short port, CallbackMethod callback);
|
|
~HttpServer();
|
|
|
|
void Wait();
|
|
|
|
private:
|
|
std::unique_ptr<HttpServerImpl> m_pHttpServerImpl;
|
|
};
|
|
|
|
} // namespace Http
|
|
|
|
#endif // HTTPSERVER_H
|