Caffa  1.1.0
C++ Application Framework for Embedded Systems with introspection
cafRestServerApplication.h
1 // ##################################################################################################
2 //
3 // Caffa
4 // Copyright (C) 2023- Kontur AS
5 //
6 // GNU Lesser General Public License Usage
7 // This library is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published by
9 // the Free Software Foundation; either version 2.1 of the License, or
10 // (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
17 // for more details.
18 //
19 #pragma once
20 
21 #include "cafNotNull.h"
22 #include "cafRpcServerApplication.h"
23 #include "cafSession.h"
24 
25 #include <utility>
26 
27 #include <boost/asio.hpp>
28 #include <boost/beast/ssl.hpp>
29 
30 #include <memory>
31 #include <vector>
32 
33 namespace net = boost::asio; // from <boost/asio.hpp>
34 namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
35 
36 namespace caffa::rpc
37 {
38 class RestServer;
39 class RestAuthenticator;
40 
46 {
47 public:
55  RestServerApplication( unsigned short portNumber, int threads, std::shared_ptr<const RestAuthenticator> authenticator );
56  static RestServerApplication* instance();
57 
58  int portNumber() const override;
59  void run() override;
60  void quit() override;
61  bool running() const override;
62 
63 private:
64  unsigned short m_portNumber;
65  int m_threads;
66  net::io_context m_ioContext;
67  std::shared_ptr<ssl::context> m_sslContext;
68  std::shared_ptr<RestServer> m_server;
69 };
70 } // namespace caffa::rpc
Definition: cafRestServerApplication.h:46
RestServerApplication(unsigned short portNumber, int threads, std::shared_ptr< const RestAuthenticator > authenticator)
Definition: cafRestServerApplication.cpp:37
Definition: cafRpcServerApplication.h:34