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