-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathHealthCheckController.cpp
More file actions
49 lines (40 loc) · 1.79 KB
/
HealthCheckController.cpp
File metadata and controls
49 lines (40 loc) · 1.79 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
#include "HealthCheckController.h"
using namespace Odb::Lib::App;
namespace Odb::App::Server
{
HealthCheckController::HealthCheckController(IOdbServerApp& serverApp)
: RouteController(serverApp)
{
}
void HealthCheckController::register_routes()
{
//register_route_handler("/health_check", std::bind(&HealthCheckController::health_check, this, std::placeholders::_1));
//register_route_handler("/health_check", [&](const crow::request& req) /*-> crow::response*/
// {
// return crow::response(crow::status::OK, "healthy");
// }
//);
register_route_handler("/healthz/live", std::bind(&HealthCheckController::health_check_live, this, std::placeholders::_1));
register_route_handler("/healthz/ready", std::bind(&HealthCheckController::health_check_ready, this, std::placeholders::_1));
register_route_handler("/healthz/started", std::bind(&HealthCheckController::health_check_started, this, std::placeholders::_1));
register_route_handler("/healthz/heartbeat", std::bind(&HealthCheckController::health_check_heartbeat, this, std::placeholders::_1));
}
crow::response HealthCheckController::health_check_live(const crow::request& req)
{
return crow::response(crow::status::OK, "txt", "healthy: live");
}
crow::response HealthCheckController::health_check_ready(const crow::request& req)
{
return crow::response(crow::status::OK, "txt", "healthy: ready");
}
crow::response HealthCheckController::health_check_started(const crow::request& req)
{
return crow::response(crow::status::OK, "txt", "healthy: started");
}
crow::response HealthCheckController::health_check_heartbeat(const crow::request& req)
{
// update last heartbeat
OdbDesignServerApp::inst_->updateLastHeartbeat();
return crow::response(crow::status::OK, "txt", "heartbeat received");
}
}