Skip to content

Commit

Permalink
Add heartbeat route
Browse files Browse the repository at this point in the history
  • Loading branch information
Su5eD committed Dec 9, 2024
1 parent cdc522c commit 7177237
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/api/v1/projects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ namespace api::v1 {
co_return true;
}

Task<> ProjectsController::greet(HttpRequestPtr req, std::function<void(const HttpResponsePtr &)> callback) const {
const auto resp = HttpResponse::newHttpResponse();
resp->setStatusCode(k200OK);
resp->setBody("Service operational");
callback(resp);
co_return;
}

Task<> ProjectsController::listIDs(HttpRequestPtr req, std::function<void(const HttpResponsePtr &)> callback) const {
const auto ids = co_await database_.getProjectIDs();

Expand Down
3 changes: 3 additions & 0 deletions src/api/v1/projects.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace api::v1 {
explicit ProjectsController(GitHub &, Platforms &, Database &, Documentation &, CloudFlare &);

METHOD_LIST_BEGIN
ADD_METHOD_TO(ProjectsController::greet, "/", drogon::Get);
ADD_METHOD_TO(ProjectsController::listIDs, "/api/v1/projects", drogon::Get, "AuthFilter");
ADD_METHOD_TO(ProjectsController::listUserProjects, "/api/v1/projects/dev?token={1:token}", drogon::Get, "AuthFilter");
ADD_METHOD_TO(ProjectsController::listPopularProjects, "/api/v1/projects/popular", drogon::Get, "AuthFilter");
Expand All @@ -31,6 +32,8 @@ namespace api::v1 {
ADD_METHOD_TO(ProjectsController::invalidate, "/api/v1/project/{1:id}/invalidate?token={2:token}", drogon::Post, "AuthFilter");
METHOD_LIST_END

drogon::Task<> greet(drogon::HttpRequestPtr req, std::function<void(const drogon::HttpResponsePtr &)> callback) const;

drogon::Task<> listIDs(drogon::HttpRequestPtr req, std::function<void(const drogon::HttpResponsePtr &)> callback) const;

drogon::Task<> listUserProjects(drogon::HttpRequestPtr req, std::function<void(const drogon::HttpResponsePtr &)> callback,
Expand Down

0 comments on commit 7177237

Please sign in to comment.