Skip to content

Commit ad169ed

Browse files
authored
Merge pull request #53 from janhq/42-add-health-check-path-in-api
42 add health check path in api
2 parents 43d72fd + a0694da commit ad169ed

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Diff for: controllers/health.cc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "health.h"
2+
3+
void health::asyncHandleHttpRequest(
4+
const HttpRequestPtr &req,
5+
std::function<void(const HttpResponsePtr &)> &&callback) {
6+
auto resp = HttpResponse::newHttpResponse();
7+
resp->setStatusCode(k200OK);
8+
resp->setContentTypeCode(CT_TEXT_HTML);
9+
resp->setBody("Nitro is alive!!!");
10+
callback(resp);
11+
}

Diff for: controllers/health.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
3+
#include <drogon/HttpSimpleController.h>
4+
#include <drogon/HttpTypes.h>
5+
6+
using namespace drogon;
7+
8+
class health : public drogon::HttpSimpleController<health>
9+
{
10+
public:
11+
void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback) override;
12+
PATH_LIST_BEGIN
13+
PATH_ADD("/healthz", Get);
14+
PATH_LIST_END
15+
};

0 commit comments

Comments
 (0)