#include "FileUtil.h" #include #include std::optional 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"; }