From 19b43a3bba7fcabecdd3de8334b971302a3dd13c Mon Sep 17 00:00:00 2001 From: chatlanin Date: Sun, 4 Aug 2024 12:29:13 +0300 Subject: [PATCH] remove api --- src/trs/trs.hpp | 11 ++--------- src/trs/utils/var.hpp | 1 + tests/main.cpp | 1 + 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/trs/trs.hpp b/src/trs/trs.hpp index f3686df..eadef58 100644 --- a/src/trs/trs.hpp +++ b/src/trs/trs.hpp @@ -73,24 +73,17 @@ namespace trs } } - void set_api_url(std::string url) - { - API_URL = url; - } - private: std::string m_service_name; bool m_log_to_console { true }; function_manager m_function_manager; inspector m_inspector; - std::string API_URL { "/" }; - private: void set_CORS() { Options(R"(\*)", [](const auto& req, auto& res) { res.set_header("Allow", "POST, HEAD, OPTIONS"); }); - Options(API_URL, [](const auto& req, auto& res) + Options(var::API_URL, [](const auto& req, auto& res) { res.set_header("Access-Control-Allow-Origin", "*"); res.set_header("Allow", "POST, HEAD, OPTIONS"); @@ -101,7 +94,7 @@ namespace trs void set_post() { - Post(API_URL, [&](const httplib::Request& req, httplib::Response& res) { + Post(var::API_URL, [&](const httplib::Request& req, httplib::Response& res) { res.set_header("Access-Control-Allow-Origin", "*"); res.set_header("Access-Control-Allow-Headers", "*"); res.set_header("Access-Control-Allow-Methods", "POST"); diff --git a/src/trs/utils/var.hpp b/src/trs/utils/var.hpp index 0dbe388..d01c16a 100644 --- a/src/trs/utils/var.hpp +++ b/src/trs/utils/var.hpp @@ -6,6 +6,7 @@ namespace trs::var { inline const int PORT = 5000; inline const std::string HOST = "0.0.0.0"; + inline const std::string API_URL = "/"; inline const std::string ALIEN_SYSTEM_ERROR = "is alien system error it can be very dangerous!!! good luck my friend!"; inline const std::string NO_VALID_DATA = "no valid data"; diff --git a/tests/main.cpp b/tests/main.cpp index f528fb7..619e91e 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -53,6 +53,7 @@ auto main(int argc, char* args[]) -> int trs::server srv; srv.init("test service"); + srv.set_api_url("/api"); srv.registration("healthcheck", worckspaces::inspector, worckspaces::provider); srv.run();