Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 92fe6e2

Browse files
committed
feat: add simple healthcheck
1 parent 43d72fd commit 92fe6e2

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

controllers/health.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "health.h"
2+
3+
void health::asyncHandleHttpRequest(
4+
const HttpRequestPtr &req,
5+
std::function<void(const HttpResponsePtr &)> &&callback) {
6+
// write your application logic here
7+
auto resp = HttpResponse::newHttpResponse();
8+
// NOTE: The enum constant below is named "k200OK" (as in 200 OK), not
9+
// "k2000K".
10+
resp->setStatusCode(k200OK);
11+
resp->setContentTypeCode(CT_TEXT_HTML);
12+
resp->setBody("Nitro is alive!!!");
13+
callback(resp);
14+
// write your application logic here
15+
}

controllers/health.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
// list path definitions here;
14+
PATH_ADD("/healthz", Get);
15+
PATH_LIST_END
16+
};

0 commit comments

Comments
 (0)