-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
#pragma once | ||
#include <drogon/HttpResponse.h> | ||
#include <drogon/HttpTypes.h> | ||
#include <drogon/drogon.h> | ||
#include <json/value.h> | ||
|
||
#include <functional> | ||
#include <jsoncons/json.hpp> | ||
#include <string> | ||
|
||
namespace api | ||
namespace api::v2 | ||
{ | ||
namespace v2 | ||
|
||
class Helper | ||
{ | ||
public: | ||
Helper() = default; | ||
Helper(const Helper&) = default; | ||
Helper(Helper&&) = delete; | ||
Helper& operator=(const Helper&) = default; | ||
Helper& operator=(Helper&&) = delete; | ||
virtual ~Helper() = default; | ||
|
||
static void failureResponse(const std::string& message, std::function<void(const drogon::HttpResponsePtr&)>&& callback); | ||
static void errorResponse( | ||
const drogon::HttpStatusCode& code, const std::string& message, std::function<void(const drogon::HttpResponsePtr&)>&& callback); | ||
static void successResponse(const std::string& message, std::function<void(const drogon::HttpResponsePtr&)>&& callback); | ||
|
||
class Helper | ||
{ | ||
public: | ||
Helper() = default; | ||
virtual ~Helper() = default; | ||
static void failureResponse(const std::string& message, | ||
std::function<void(const drogon::HttpResponsePtr&)>&& callback); | ||
static void errorResponse(const drogon::HttpStatusCode& code, const std::string& message, | ||
std::function<void(const drogon::HttpResponsePtr&)>&& callback); | ||
static void successResponse(const std::string& message, | ||
std::function<void(const drogon::HttpResponsePtr&)>&& callback); | ||
private: | ||
static void reply(std::function<void(const drogon::HttpResponsePtr&)>&& callback, const drogon::HttpStatusCode& code, const std::string& message); | ||
static std::string prepare(const std::string& status, const std::string& message); | ||
|
||
private: | ||
static void reply(std::function<void(const drogon::HttpResponsePtr&)>&& callback, | ||
const drogon::HttpStatusCode& code, const std::string& message); | ||
static std::string prepare(const std::string& status, const std::string& message); | ||
}; | ||
} // namespace v2 | ||
} // namespace api | ||
static constexpr const char* FAILURE = "Failure"; | ||
static constexpr const char* ERROR = "Error"; | ||
}; | ||
} // namespace api::v2 |