-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathApp.cpp
More file actions
52 lines (35 loc) · 1.43 KB
/
Copy pathApp.cpp
File metadata and controls
52 lines (35 loc) · 1.43 KB
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
51
52
#include "./controller/MyController.hpp"
#include "./AppComponent.hpp"
#include "oatpp/network/Server.hpp"
#include <iostream>
/**
* run() method.
* 1) set Environment components.
* 2) add ApiController's endpoints to router
* 3) run server
*/
void run() {
AppComponent components; // Create scope Environment components
/* create ApiControllers and add endpoints to router */
auto router = components.httpRouter.getObject();
router->addController(MyController::createShared());
/* create server */
oatpp::network::Server server(components.serverConnectionProvider.getObject(),
components.serverConnectionHandler.getObject());
OATPP_LOGD("Server", "Running on port %s...", components.serverConnectionProvider.getObject()->getProperty("port").toString()->c_str());
server.run();
}
/**
* main
*/
int main(int argc, const char * argv[]) {
oatpp::base::Environment::init();
run();
/* Print how much objects were created during app running, and what have left-probably leaked */
/* Disable object counting for release builds using '-D OATPP_DISABLE_ENV_OBJECT_COUNTERS' flag for better performance */
std::cout << "\nEnvironment:\n";
std::cout << "objectsCount = " << oatpp::base::Environment::getObjectsCount() << "\n";
std::cout << "objectsCreated = " << oatpp::base::Environment::getObjectsCreated() << "\n\n";
oatpp::base::Environment::destroy();
return 0;
}