diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index bc14851f9..f94a82990 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -877,7 +877,9 @@ std::unique_ptr InternalServer::handle_raw(const RequestContext& reque if (archive == nullptr) { const std::string error_details = "No such book: " + bookName; - return Response::build_404(*this, request.get_full_url(), error_details); + return HTTP404HtmlResponse(*this, request) + + urlNotFoundMsg + + error_details; } // Remove the beggining of the path: diff --git a/src/server/response.cpp b/src/server/response.cpp index f07a1e6d2..da6fe00b7 100644 --- a/src/server/response.cpp +++ b/src/server/response.cpp @@ -127,8 +127,12 @@ HTTP404HtmlResponse& HTTP404HtmlResponse::operator+(UrlNotFoundMsg /*unused*/) { const std::string requestUrl = m_request.get_full_url(); kainjow::mustache::mustache msgTmpl(R"(The requested URL "{{url}}" was not found on this server.)"); - const auto urlNotFoundMsgText = msgTmpl.render({"url", requestUrl}); - m_data["details"].push_back({"p", urlNotFoundMsgText}); + return *this + msgTmpl.render({"url", requestUrl}); +} + +HTTP404HtmlResponse& HTTP404HtmlResponse::operator+(const std::string& msg) +{ + m_data["details"].push_back({"p", msg}); return *this; } diff --git a/src/server/response.h b/src/server/response.h index 7826d3e72..ee45e1d3f 100644 --- a/src/server/response.h +++ b/src/server/response.h @@ -185,6 +185,7 @@ struct HTTP404HtmlResponse : ContentResponseBlueprint const RequestContext& request); HTTP404HtmlResponse& operator+(UrlNotFoundMsg /*unused*/); + HTTP404HtmlResponse& operator+(const std::string& errorDetails); }; class ItemResponse : public Response {