Use url parsing
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user