-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhttp_server.h
41 lines (33 loc) · 1.09 KB
/
http_server.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) 2022, Eugene Gershnik
// SPDX-License-Identifier: BSD-3-Clause
#ifndef HEADER_HTTP_SERVER_H_INCLUDED
#define HEADER_HTTP_SERVER_H_INCLUDED
#include "config.h"
#include "xml_wrapper.h"
struct NetworkInterface;
class HttpServer : public ref_counted<HttpServer> {
friend ref_counted<HttpServer>;
public:
class Handler {
public:
virtual auto handleHttpRequest(std::unique_ptr<XmlDoc> doc) -> std::optional<XmlCharBuffer> = 0;
virtual void onFatalHttpError() = 0;
protected:
~Handler() {}
};
public:
virtual void start(Handler & handler) = 0;
virtual void stop() = 0;
protected:
HttpServer() {
}
virtual ~HttpServer() noexcept {
}
};
using HttpServerFactoryT = auto (asio::io_context & ctxt,
const refcnt_ptr<Config> & config,
const NetworkInterface & iface,
const ip::tcp::endpoint & endpoint) -> refcnt_ptr<HttpServer>;
using HttpServerFactory = std::function<HttpServerFactoryT>;
HttpServerFactoryT createHttpServer;
#endif