base of maps routes

This commit is contained in:
Антон 2024-03-20 18:40:04 +03:00
parent ac9c40058b
commit b2f0a8d4c3
1 changed files with 36 additions and 14 deletions

View File

@ -5,6 +5,7 @@
#include <mutex>
#include <thread>
#include <vector>
#include <fstream>
#include "src/http_server.h"
@ -32,11 +33,33 @@ struct content_type
StringResponse HandleRequest(StringRequest&& req)
{
auto route = req.target();
constexpr static string_view k_MapsPattern = "/api/v1/maps"sv;
const auto route = req.target();
switch (true)
if (equal(k_MapsPattern.begin(),
k_MapsPattern.end(),
route.begin(),
route.end()))
{
default:
ifstream stream("./config.json"s);
string config;
string buf;
while (std::getline(stream, buf))
{
config += buf;
}
auto r = config;
}
else if (equal(k_MapsPattern.begin(),
k_MapsPattern.end(),
route.begin(),
route.begin() + k_MapsPattern.size()))
{
}
else
{
StringResponse res(http::status::bad_request, 1);
res.set(http::field::content_type, content_type::k_JSON);
@ -51,7 +74,6 @@ StringResponse HandleRequest(StringRequest&& req)
return res;
}
}
}
// Запускает функцию fn на n потоках, включая текущий
template<typename Fn>