NotFound middleware returns prettier error
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "../http/mime.hpp"
|
||||
#include "notfound.hpp"
|
||||
#include <sstream>
|
||||
|
||||
@@ -11,17 +12,17 @@ namespace Middleware
|
||||
}
|
||||
|
||||
response.code = HttpResponse::Code::NOT_FOUND;
|
||||
response.contentType = Http::GetMimeType(Http::FileType::HTML);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "404 - file not found\n";
|
||||
ss << "File: ";
|
||||
ss << request.url.GetPath() << '\n';
|
||||
ss << "<!DOCTYPE html><html><head></head><body>";
|
||||
ss << "<h1>404 - File Not Found</h1>";
|
||||
ss << "<p>File: " << request.url.GetPath() << "<p>";
|
||||
ss << "</body></html>";
|
||||
|
||||
auto responseContent = ss.str();
|
||||
response.content.insert(response.content.begin(),
|
||||
responseContent.begin(),
|
||||
responseContent.end());
|
||||
|
||||
response.contentType = "text/plain";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user