1 #include "OdbServerAppBase.h"
2 #include "OdbServerAppBase.h"
6 using namespace std::filesystem;
8 namespace Odb::Lib::App
10 OdbServerAppBase::OdbServerAppBase(
int argc,
char* argv[])
11 : OdbAppBase(argc, argv)
15 bool OdbServerAppBase::preServerRun()
21 bool OdbServerAppBase::postServerRun()
27 OdbServerAppBase::~OdbServerAppBase()
29 m_vecControllers.clear();
32 ExitCode OdbServerAppBase::Run()
38 return ExitCode::Success;
42 if (ExitCode::Success != OdbAppBase::Run())
return ExitCode::FailedInit;
45 m_crowApp.loglevel(crow::LogLevel::Info);
48 m_crowApp.use_compression(crow::compression::algorithm::GZIP);
52 if (args().useHttps())
54 path sslDirPath(args().sslDir());
55 if (!exists(sslDirPath) || !is_directory(sslDirPath))
57 logerror(
"SSL was specified but the directory does not exist, exiting...");
58 return ExitCode::FailedInitSslDirDoesNotExist;
62 m_crowApp.ssl_file((sslDirPath / SSL_CERT_FILE).
string(),
63 (sslDirPath / SSL_KEY_FILE).
string());
66 catch (boost::wrapexcept<boost::system::system_error>& e)
70 logerror(
"SSL was specified but it failed to initialize, exiting...");
71 return ExitCode::FailedInitSsl;
81 m_crowApp.port(
static_cast<unsigned short>(args().port()));
84 m_crowApp.multithreaded();
86 if (!preServerRun())
return ExitCode::PreServerRunFailed;
91 if (!postServerRun())
return ExitCode::PostServerRunFailed;
94 return ExitCode::Success;
97 CrowApp& OdbServerAppBase::crow_app()
102 RequestAuthenticationBase& OdbServerAppBase::request_auth()
104 return *m_pRequestAuthentication;
107 void OdbServerAppBase::request_auth(std::unique_ptr<RequestAuthenticationBase> pRequestAuthentication)
109 m_pRequestAuthentication = std::move(pRequestAuthentication);
112 void OdbServerAppBase::register_routes()
114 for (
const auto& pController : m_vecControllers)
116 pController->register_routes();