base of maps routes
This commit is contained in:
parent
ac9c40058b
commit
b2f0a8d4c3
30
main.cpp
30
main.cpp
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user