mirror of https://github.com/kiwix/libkiwix.git
HTTP404HtmlResponse::operator+(const std::string&)
This commit is contained in:
parent
d5ae92e4e2
commit
48d377ca44
|
@ -877,7 +877,9 @@ std::unique_ptr<Response> InternalServer::handle_raw(const RequestContext& reque
|
||||||
|
|
||||||
if (archive == nullptr) {
|
if (archive == nullptr) {
|
||||||
const std::string error_details = "No such book: " + bookName;
|
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:
|
// Remove the beggining of the path:
|
||||||
|
|
|
@ -127,8 +127,12 @@ HTTP404HtmlResponse& HTTP404HtmlResponse::operator+(UrlNotFoundMsg /*unused*/)
|
||||||
{
|
{
|
||||||
const std::string requestUrl = m_request.get_full_url();
|
const std::string requestUrl = m_request.get_full_url();
|
||||||
kainjow::mustache::mustache msgTmpl(R"(The requested URL "{{url}}" was not found on this server.)");
|
kainjow::mustache::mustache msgTmpl(R"(The requested URL "{{url}}" was not found on this server.)");
|
||||||
const auto urlNotFoundMsgText = msgTmpl.render({"url", requestUrl});
|
return *this + msgTmpl.render({"url", requestUrl});
|
||||||
m_data["details"].push_back({"p", urlNotFoundMsgText});
|
}
|
||||||
|
|
||||||
|
HTTP404HtmlResponse& HTTP404HtmlResponse::operator+(const std::string& msg)
|
||||||
|
{
|
||||||
|
m_data["details"].push_back({"p", msg});
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,7 @@ struct HTTP404HtmlResponse : ContentResponseBlueprint
|
||||||
const RequestContext& request);
|
const RequestContext& request);
|
||||||
|
|
||||||
HTTP404HtmlResponse& operator+(UrlNotFoundMsg /*unused*/);
|
HTTP404HtmlResponse& operator+(UrlNotFoundMsg /*unused*/);
|
||||||
|
HTTP404HtmlResponse& operator+(const std::string& errorDetails);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ItemResponse : public Response {
|
class ItemResponse : public Response {
|
||||||
|
|
Loading…
Reference in New Issue