updated and added more funcs to be small
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Has been cancelled
This commit is contained in:
1 parent
11028cb567
commit
782315b9f4
8 files changed
+29
-77
No files matched your search
+15
-8
@@ -1,13 +1,20 @@
|
||||
#pragma once
|
||||
#include <httplib.h>
|
||||
#include <json.hpp>
|
||||
#include <syslog.h>
|
||||
|
||||
static bool check_body(const httplib::Request& request)
|
||||
{
|
||||
if (request.body.empty())
|
||||
return false;
|
||||
nlohmann::json json_body = nlohmann::json::parse(request.body);
|
||||
if (json_body["token"] == nullptr)
|
||||
return false;
|
||||
return true;
|
||||
inline void check_body_empty(const httplib::Request& request, httplib::Response& response, std::string required_string) {
|
||||
if (request.body.empty()) {
|
||||
response.set_content(required_string, JSON_TYPE);
|
||||
syslog(LOG_ERR, "no body in request");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
inline void check_body_data(nlohmann::json body, std::string data, httplib::Response& response, std::string required_string) {
|
||||
if (body[data] == nullptr) {
|
||||
response.set_content(required_string, JSON_TYPE);
|
||||
syslog(LOG_ERR, "Error request");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user