-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathApp.cpp
50 lines (30 loc) · 1.34 KB
/
App.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "controller/UserController.hpp"
#include "AppComponent.hpp"
#include "DatabaseComponent.hpp"
#include "ServiceComponent.hpp"
#include "SwaggerComponent.hpp"
#include "oatpp-swagger/Controller.hpp"
#include "oatpp/network/Server.hpp"
#include <iostream>
void run(const oatpp::base::CommandLineArguments& args) {
AppComponent appComponent(args);
ServiceComponent serviceComponent;
SwaggerComponent swaggerComponent;
DatabaseComponent databaseComponent;
/* create ApiControllers and add endpoints to router */
auto router = serviceComponent.httpRouter.getObject();
oatpp::web::server::api::Endpoints docEndpoints;
docEndpoints.append(router->addController(UserController::createShared())->getEndpoints());
router->addController(oatpp::swagger::Controller::createShared(docEndpoints));
/* create server */
oatpp::network::Server server(serviceComponent.serverConnectionProvider.getObject(),
serviceComponent.serverConnectionHandler.getObject());
OATPP_LOGD("Server", "Running on port %s...", serviceComponent.serverConnectionProvider.getObject()->getProperty("port").toString()->c_str());
server.run();
}
int main(int argc, const char * argv[]) {
oatpp::base::Environment::init();
run(oatpp::base::CommandLineArguments(argc, argv));
oatpp::base::Environment::destroy();
return 0;
}