From 92fe6e2bda265e82ae5dcfebb8b5c2bff725d559 Mon Sep 17 00:00:00 2001 From: tikikun Date: Thu, 5 Oct 2023 15:04:37 +0700 Subject: [PATCH 1/2] feat: add simple healthcheck --- controllers/health.cc | 15 +++++++++++++++ controllers/health.h | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 controllers/health.cc create mode 100644 controllers/health.h diff --git a/controllers/health.cc b/controllers/health.cc new file mode 100644 index 000000000..75580411a --- /dev/null +++ b/controllers/health.cc @@ -0,0 +1,15 @@ +#include "health.h" + +void health::asyncHandleHttpRequest( + const HttpRequestPtr &req, + std::function &&callback) { + // write your application logic here + auto resp = HttpResponse::newHttpResponse(); + // NOTE: The enum constant below is named "k200OK" (as in 200 OK), not + // "k2000K". + resp->setStatusCode(k200OK); + resp->setContentTypeCode(CT_TEXT_HTML); + resp->setBody("Nitro is alive!!!"); + callback(resp); + // write your application logic here +} diff --git a/controllers/health.h b/controllers/health.h new file mode 100644 index 000000000..4457f5da2 --- /dev/null +++ b/controllers/health.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +using namespace drogon; + +class health : public drogon::HttpSimpleController +{ + public: + void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function &&callback) override; + PATH_LIST_BEGIN + // list path definitions here; + PATH_ADD("/healthz", Get); + PATH_LIST_END +}; From a0694daa0ef11169aea7e350c4f1ad0c3e5fdd72 Mon Sep 17 00:00:00 2001 From: tikikun Date: Thu, 5 Oct 2023 15:11:00 +0700 Subject: [PATCH 2/2] feat: add simple healthcheck --- controllers/health.cc | 4 ---- controllers/health.h | 1 - 2 files changed, 5 deletions(-) diff --git a/controllers/health.cc b/controllers/health.cc index 75580411a..79b3d33f5 100644 --- a/controllers/health.cc +++ b/controllers/health.cc @@ -3,13 +3,9 @@ void health::asyncHandleHttpRequest( const HttpRequestPtr &req, std::function &&callback) { - // write your application logic here auto resp = HttpResponse::newHttpResponse(); - // NOTE: The enum constant below is named "k200OK" (as in 200 OK), not - // "k2000K". resp->setStatusCode(k200OK); resp->setContentTypeCode(CT_TEXT_HTML); resp->setBody("Nitro is alive!!!"); callback(resp); - // write your application logic here } diff --git a/controllers/health.h b/controllers/health.h index 4457f5da2..c45d92b8e 100644 --- a/controllers/health.h +++ b/controllers/health.h @@ -10,7 +10,6 @@ class health : public drogon::HttpSimpleController public: void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function &&callback) override; PATH_LIST_BEGIN - // list path definitions here; PATH_ADD("/healthz", Get); PATH_LIST_END };