Use url parsing

This commit is contained in:
2019-06-15 20:52:40 +02:00
parent 22d5430e57
commit 71a7aa147c
10 changed files with 126 additions and 71 deletions

View File

@@ -34,24 +34,18 @@ namespace Middleware
}
std::filesystem::path path;
if (request.path.size() == 1)
if (request.url.HasPath())
{
path = root + request.url.GetPath();
}
else
{
// TODO make configurable?
path = root + "/index.html";
}
else
{
path = root + request.path;
}
if (!std::filesystem::exists(path))
{
std::stringstream ss;
ss << "Static file <";
ss << path.string();
ss << "> not found";
Logger::GetInstance().Info(ss.str());
return;
}