ADTF
Loading...
Searching...
No Matches
threaded_http_server.h
Go to the documentation of this file.
1
14
15#ifndef PKG_RPC_RPC_DETAIL_THREAD_HTTP_SERVER_H_
16#define PKG_RPC_RPC_DETAIL_THREAD_HTTP_SERVER_H_
17
19
20#include <map>
21#include <memory>
22#include <string>
23
24namespace rpc {
25namespace http {
26
28namespace detail {
29
30class cThreadedHttpServer {
31public:
32 cThreadedHttpServer();
33 ~cThreadedHttpServer();
34 cThreadedHttpServer(const cThreadedHttpServer&) = delete;
35 cThreadedHttpServer& operator=(const cThreadedHttpServer&) = delete;
36 cThreadedHttpServer(cThreadedHttpServer&&) = default;
37 cThreadedHttpServer& operator=(cThreadedHttpServer&&) = default;
38
44 a_util::result::Result StartListening(const char* strURL, int reuse = 1);
45
50 a_util::result::Result StopListening();
51
52protected:
53 virtual bool HandleRequest(const std::string& strUrl,
54 const std::string& strRequest,
55 std::string& strResponse,
56 std::string& strContentType) = 0;
57
58 struct tRequest {
59 const std::string& method;
60 const std::string& url;
61 const std::multimap<std::string, std::string>& headers;
62 const std::string& body;
63 const std::map<std::string, std::string>& params;
64 };
65
66 struct tResponse {
67 int& status;
68 std::multimap<std::string, std::string>& headers;
69 std::string& body;
70 };
71
72 virtual bool HandleRequest(const tRequest& sRequest, tResponse& sResponse);
73
74private:
75 class cImplementation;
76 std::unique_ptr<cImplementation> m_pImplementation;
77};
78
79} // namespace detail
81} // namespace http
82} // namespace rpc
83
84#endif
definition of the http namespace
Definition http_rpc_server.h:23
definition of the rpc namespace
Definition json_rpc_impl.h:20