OdbDesignLib
OdbDesign ODB++ Parsing Library
OdbServerAppBase.h
1 #pragma once
2 
3 #include "IOdbServerApp.h"
4 #include "OdbAppBase.h"
5 #include "RouteController.h"
6 #include "../odbdesign_export.h"
7 #include "RequestAuthenticationBase.h"
8 #include "BasicRequestAuthentication.h"
9 
10 namespace Odb::Lib::App
11 {
12  class ODBDESIGN_EXPORT OdbServerAppBase : public OdbAppBase, public IOdbServerApp
13  {
14  public:
15  virtual ~OdbServerAppBase();
16 
17  CrowApp& crow_app() override;
18 
19  RequestAuthenticationBase& request_auth() override;
20  void request_auth(std::unique_ptr<RequestAuthenticationBase> pRequestAuthentication) override;
21 
22  Utils::ExitCode Run() override;
23 
24  protected:
25  OdbServerAppBase(int argc, char* argv[]);
26 
27  RouteController::Vector m_vecControllers;
28 
29  // implement in subclasses to add route controllers
30  virtual void add_controllers() = 0;
31 
32  virtual bool preServerRun();
33  virtual bool postServerRun();
34 
35  private:
36  CrowApp m_crowApp;
37  //crow::SimpleApp m_crowApp;
38  std::unique_ptr<RequestAuthenticationBase> m_pRequestAuthentication;
39 
40  void register_routes();
41 
42  static constexpr const char* SSL_CERT_FILE = "ssl.crt";
43  static constexpr const char* SSL_KEY_FILE = "ssl.key";
44  };
45 }