A new overload of Response::build_404()

This commit is contained in:
Veloman Yunkan 2022-01-22 18:15:19 +04:00 committed by Matthieu Gautier
parent 26c16bb1b2
commit 8cfcf2ea86
2 changed files with 7 additions and 0 deletions

View File

@ -92,12 +92,18 @@ std::unique_ptr<ContentResponse> Response::build_404(const InternalServer& serve
}
data.set("details", details);
return build_404(server, data);
}
std::unique_ptr<ContentResponse> Response::build_404(const InternalServer& server, const kainjow::mustache::data& data)
{
auto response = ContentResponse::build(server, RESOURCE::templates::_404_html, data, "text/html");
response->set_code(MHD_HTTP_NOT_FOUND);
return response;
}
std::unique_ptr<Response> Response::build_416(const InternalServer& server, size_t resourceLength)
{
auto response = Response::build(server);

View File

@ -51,6 +51,7 @@ class Response {
static std::unique_ptr<Response> build(const InternalServer& server);
static std::unique_ptr<Response> build_304(const InternalServer& server, const ETag& etag);
static std::unique_ptr<ContentResponse> build_404(const InternalServer& server, const kainjow::mustache::data& data);
static std::unique_ptr<ContentResponse> build_404(const InternalServer& server, const std::string& url, const std::string& details="");
static std::unique_ptr<Response> build_416(const InternalServer& server, size_t resourceLength);
static std::unique_ptr<Response> build_500(const InternalServer& server, const std::string& msg);