diff options
author | Niklas Halle <niklas@niklashalle.net> | 2020-08-24 19:04:13 +0200 |
---|---|---|
committer | Niklas Halle <niklas@niklashalle.net> | 2020-08-24 19:04:13 +0200 |
commit | 38e20390ddf38edd74447ef7db2af660b8e0ff32 (patch) | |
tree | 19139ea991ae5d99b28d5c1f9f509ff0ebf4b151 /src/Response.cpp | |
parent | 61464b6d069513eda07e4fc2638c8889cbce98f5 (diff) | |
download | n_core-38e20390ddf38edd74447ef7db2af660b8e0ff32.tar.gz n_core-38e20390ddf38edd74447ef7db2af660b8e0ff32.zip |
add all available commands (in this branch? @Max where are the others?)
Diffstat (limited to 'src/Response.cpp')
-rw-r--r-- | src/Response.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Response.cpp b/src/Response.cpp new file mode 100644 index 0000000..050a537 --- /dev/null +++ b/src/Response.cpp @@ -0,0 +1,36 @@ +#include "Response.hpp" + +Response::json Response::simple_response(std::string const &text, std::string const &session, bool success) { + std::vector<json> reply_vec; + reply_vec.emplace_back(create_text(text)); + + return create_response(std::move(reply_vec), session, success); +} + +Response::json Response::create_annotation(Reply::AnnotationType annotationType, std::string const &extra) { + json annotation(crow::json::type::Object); + annotation["type"] = Reply::GetStringAnnotationType(annotationType); + annotation["extra"] = extra; + return annotation; +} + +Response::json Response::create_text(std::string const &text) { + std::vector<json> annotations; + annotations.emplace_back(create_annotation()); + return create_text(text, std::move(annotations)); +} + +Response::json Response::create_text(std::string const &text, std::vector<json> &&annotations) { + json reply(crow::json::type::Object); + reply["text"] = text; + reply["annotations"] = std::move(annotations); + return reply; +} + +Response::json Response::create_response(std::vector<json> &&reply, std::string const &session, bool success) { + json response(crow::json::type::Object); + response["success"] = success; + response["session"] = session; + response["reply"] = std::move(reply); + return response; +}
\ No newline at end of file |