diff --git a/CMakeLists.txt b/CMakeLists.txt
index fdcf98f..12b935f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,6 +35,8 @@ add_executable(hello_async
src/content_type.h
src/handlers/GetMapByIdHandler.cpp
src/handlers/GetMapByIdHandler.h
+ src/handlers/GetStaticAssetHandler.cpp
+ src/handlers/GetStaticAssetHandler.h
src/routes.h)
target_include_directories(hello_async PUBLIC ${Boost_INCLUDE_DIR})
target_link_libraries(hello_async PRIVATE Threads::Threads Boost::filesystem Boost::json)
diff --git a/main.cpp b/main.cpp
index 297fac8..57fd880 100644
--- a/main.cpp
+++ b/main.cpp
@@ -13,6 +13,7 @@
#include "src/routes.h"
#include "src/handlers/GetMapsHandler.h"
#include "src/handlers/GetMapByIdHandler.h"
+#include "src/handlers/GetStaticAssetHandler.h"
namespace
{
@@ -34,6 +35,11 @@ StringResponse HandleRequest(StringRequest&& req)
{
const auto route = req.target();
+ if (req.target() == "/"sv || find(route.begin(), route.end(), '.') != route.end())
+ {
+ return GetStaticAssetHandler(req);
+ }
+
if (equal(k_MapsRoute.begin(),
k_MapsRoute.end(),
route.begin(),
diff --git a/public/index.html b/public/index.html
new file mode 100644
index 0000000..442d297
--- /dev/null
+++ b/public/index.html
@@ -0,0 +1,10 @@
+
+
+
+
+ My title
+
+
+123412341324
+
+
\ No newline at end of file
diff --git a/src/handlers/GetStaticAssetHandler.cpp b/src/handlers/GetStaticAssetHandler.cpp
new file mode 100644
index 0000000..41c1900
--- /dev/null
+++ b/src/handlers/GetStaticAssetHandler.cpp
@@ -0,0 +1,27 @@
+#include "GetMapsHandler.h"
+
+#include
+#include
+#include
+
+namespace fs = std::filesystem;
+using namespace std;
+
+namespace http_server
+{
+StringResponse GetStaticAssetHandler(const StringRequest& req)
+{
+ string rel_path_str {req.target().begin(), req.target().end()};
+ fs::path base_path("./public/"s);
+ fs::path rel_path(rel_path_str);
+ fs::path abs_path = fs::weakly_canonical(base_path / rel_path);
+
+ StringResponse res(http::status::ok, 1);
+ res.set(http::field::content_type, content_type::k_JSON);
+ res.body() = "INVALID";
+ res.content_length(res.body().size());
+ res.keep_alive(true);
+
+ return res;
+}
+}
diff --git a/src/handlers/GetStaticAssetHandler.h b/src/handlers/GetStaticAssetHandler.h
new file mode 100644
index 0000000..a9f534a
--- /dev/null
+++ b/src/handlers/GetStaticAssetHandler.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+
+#include "../content_type.h"
+
+namespace http_server
+{
+namespace net = boost::asio;
+using namespace std::literals;
+namespace sys = boost::system;
+namespace json = boost::json;
+namespace http = boost::beast::http;
+using namespace std;
+using net::ip::tcp;
+
+using StringRequest = http::request;
+using StringResponse = http::response;
+
+StringResponse GetStaticAssetHandler(const StringRequest&);
+}