diff --git a/main.cpp b/main.cpp index 6b7707d..57a35e1 100644 --- a/main.cpp +++ b/main.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "src/http_server.h" @@ -32,24 +33,45 @@ 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: - { - StringResponse res(http::status::bad_request, 1); - res.set(http::field::content_type, content_type::k_JSON); - string body = "{\n" - " \"code\": \"badRequest\",\n" - " \"message\": \"Bad request\"\n" - "} "s; - res.body() = body; - res.content_length(body.size()); - res.keep_alive(true); + ifstream stream("./config.json"s); + string config; + string buf; - return res; + 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); + string body = "{\n" + " \"code\": \"badRequest\",\n" + " \"message\": \"Bad request\"\n" + "} "s; + res.body() = body; + res.content_length(body.size()); + res.keep_alive(true); + + return res; } }