Intial somewhat working version

This commit is contained in:
2026-05-02 14:20:38 +10:00
commit a76d37c2e8
28 changed files with 2572 additions and 0 deletions

29
src/FileUtil.cpp Normal file
View File

@@ -0,0 +1,29 @@
#include "FileUtil.h"
#include <fstream>
#include <sstream>
std::optional<std::string> readTextFile(const std::filesystem::path& path)
{
std::ifstream file(path, std::ios::binary);
if (!file)
return std::nullopt;
std::ostringstream buffer;
buffer << file.rdbuf();
return buffer.str();
}
std::string contentTypeForPath(const std::filesystem::path& path)
{
const auto ext = path.extension().string();
if (ext == ".html")
return "text/html; charset=utf-8";
if (ext == ".css")
return "text/css; charset=utf-8";
if (ext == ".js")
return "application/javascript; charset=utf-8";
if (ext == ".json")
return "application/json; charset=utf-8";
return "application/octet-stream";
}