This commit is contained in:
Nicholas Orlowsky 2023-10-20 00:27:35 -04:00
parent f1868ceea5
commit dea773366e
No known key found for this signature in database
GPG key ID: BE7DF0188A405E2B
8 changed files with 103 additions and 24 deletions

View file

@ -11,9 +11,9 @@ private:
filename = file_dir + filename;
auto file_info = file_cache.find(filename);
int status = 200;
int status = http_status_codes::OK;
if (file_info == file_cache.end()) {
status = 404;
status = http_status_codes::NOT_FOUND;
filename = "./error_pages/404.html";
file_info = file_cache.find(filename);
}
@ -43,10 +43,12 @@ private:
}
public:
file_backend(std::string dir = "./www") : file_dir(dir) {
file_backend(std::string dir = "./www") : file_dir(std::move(dir)) {
populate_cache();
}
~file_backend() = default;
std::unique_ptr<http_response> handle_request(http_request& req) override {
return handle_request_cache(req);
}