Files
openrouter/src/system/reboot/reboot.cpp
T
wt 782315b9f4
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
updated and added more funcs to be small
2025-04-19 17:03:56 +07:00

28 lines
885 B
C++

#include <system/reboot/reboot.hpp>
#include <json.hpp>
#include <colors.h>
#include <types.hpp>
#include <auth/auth.hpp>
#include <helpers.hpp>
namespace api
{
namespace system
{
void reboot(const httplib::Request& request, httplib::Response& response)
{
std::cout << GREEN << request.path << RESET << " " << request.method << std::endl;
response.set_header("Access-Control-Allow-Origin", "*");
check_body_empty(request, response, ACCESS_REQUIRED_STRING);
nlohmann::json json_body = nlohmann::json::parse(request.body);
check_body_data(json_body, "token", response, ACCESS_REQUIRED_STRING);
if (authenticate(json_body["token"]))
{
std::system("reboot");
}
response.set_content(R"({"access":"reject"})", JSON_TYPE);
}
}
}