From c143034c003421682bbd8b29d50401c5a19b4d53 Mon Sep 17 00:00:00 2001 From: Ian Roddis Date: Wed, 12 Jan 2022 15:17:00 -0400 Subject: [PATCH] Implementing a redirect for a GET on / to list of dagruns --- daggyd/libdaggyd/include/daggyd/Server.hpp | 1 + daggyd/libdaggyd/src/Server.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/daggyd/libdaggyd/include/daggyd/Server.hpp b/daggyd/libdaggyd/include/daggyd/Server.hpp index b9b7d91..dabc956 100644 --- a/daggyd/libdaggyd/include/daggyd/Server.hpp +++ b/daggyd/libdaggyd/include/daggyd/Server.hpp @@ -40,6 +40,7 @@ namespace daggy::daggyd { void queueDAG_(DAGRunID runID, const TaskDAG &dag, const TaskParameters &taskParameters); + DAGGY_REST_HANDLER(handleRoot); // X DAGGY_REST_HANDLER(handleReady); // X DAGGY_REST_HANDLER(handleQueryDAGs); // X DAGGY_REST_HANDLER(handleRunDAG); // X diff --git a/daggyd/libdaggyd/src/Server.cpp b/daggyd/libdaggyd/src/Server.cpp index d57f526..43314b2 100644 --- a/daggyd/libdaggyd/src/Server.cpp +++ b/daggyd/libdaggyd/src/Server.cpp @@ -101,6 +101,11 @@ namespace daggy::daggyd { .response(Http::Code::Ok, "Response to the /ready call") .hide(); + desc_.route(desc_.get("/")) + .bind(&Server::handleRoot, this) + .response(Http::Code::Ok, "Response to the /ready call") + .hide(); + auto versionPath = desc_.path("/v1"); /* @@ -646,6 +651,15 @@ namespace daggy::daggyd { response.send(Pistache::Http::Code::Ok, R"({ "msg": "Ya like DAGs?"}\n)"); } + void Server::handleRoot(const Pistache::Rest::Request &request, + Pistache::Http::ResponseWriter response) + { + response.headers().add( + std::make_shared("/v1/dagruns")); + response.send(Pistache::Http::Code::Moved_Permanently, + R"({ "msg": "These are the dags you are looking for"}\n)"); + } + /* * handleAuth will check any auth methods and handle any responses in the * case of failed auth. If it returns false, callers should cease handling