mirror of https://github.com/kiwix/libkiwix.git
Reused HTTPErrorHtmlResponse in HTTP400HtmlResponse
This commit is contained in:
parent
89dc9afc28
commit
545d409150
|
@ -141,17 +141,15 @@ HTTPErrorHtmlResponse& HTTPErrorHtmlResponse::operator+(const std::string& msg)
|
||||||
|
|
||||||
HTTP400HtmlResponse::HTTP400HtmlResponse(const InternalServer& server,
|
HTTP400HtmlResponse::HTTP400HtmlResponse(const InternalServer& server,
|
||||||
const RequestContext& request)
|
const RequestContext& request)
|
||||||
: ContentResponseBlueprint(&server,
|
: HTTPErrorHtmlResponse(server,
|
||||||
&request,
|
request,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"text/html",
|
"Invalid request",
|
||||||
RESOURCE::templates::_400_html)
|
"Invalid request")
|
||||||
{
|
{
|
||||||
kainjow::mustache::list emptyList;
|
|
||||||
this->m_data = kainjow::mustache::object{{"details", emptyList}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTP400HtmlResponse& HTTP400HtmlResponse::operator+(InvalidUrlMsg /*unused*/)
|
HTTPErrorHtmlResponse& HTTP400HtmlResponse::operator+(InvalidUrlMsg /*unused*/)
|
||||||
{
|
{
|
||||||
std::string requestUrl = m_request.get_full_url();
|
std::string requestUrl = m_request.get_full_url();
|
||||||
const auto query = m_request.get_query();
|
const auto query = m_request.get_query();
|
||||||
|
@ -162,13 +160,6 @@ HTTP400HtmlResponse& HTTP400HtmlResponse::operator+(InvalidUrlMsg /*unused*/)
|
||||||
return *this + msgTmpl.render({"url", requestUrl});
|
return *this + msgTmpl.render({"url", requestUrl});
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTP400HtmlResponse& HTTP400HtmlResponse::operator+(const std::string& msg)
|
|
||||||
{
|
|
||||||
m_data["details"].push_back({"p", msg});
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ContentResponseBlueprint& ContentResponseBlueprint::operator+(const TaskbarInfo& taskbarInfo)
|
ContentResponseBlueprint& ContentResponseBlueprint::operator+(const TaskbarInfo& taskbarInfo)
|
||||||
{
|
{
|
||||||
this->m_taskbarInfo.reset(new TaskbarInfo(taskbarInfo));
|
this->m_taskbarInfo.reset(new TaskbarInfo(taskbarInfo));
|
||||||
|
|
|
@ -208,14 +208,13 @@ class InvalidUrlMsg {};
|
||||||
|
|
||||||
extern const InvalidUrlMsg invalidUrlMsg;
|
extern const InvalidUrlMsg invalidUrlMsg;
|
||||||
|
|
||||||
struct HTTP400HtmlResponse : ContentResponseBlueprint
|
struct HTTP400HtmlResponse : HTTPErrorHtmlResponse
|
||||||
{
|
{
|
||||||
HTTP400HtmlResponse(const InternalServer& server,
|
HTTP400HtmlResponse(const InternalServer& server,
|
||||||
const RequestContext& request);
|
const RequestContext& request);
|
||||||
|
|
||||||
using ContentResponseBlueprint::operator+;
|
using HTTPErrorHtmlResponse::operator+;
|
||||||
HTTP400HtmlResponse& operator+(InvalidUrlMsg /*unused*/);
|
HTTPErrorHtmlResponse& operator+(InvalidUrlMsg /*unused*/);
|
||||||
HTTP400HtmlResponse& operator+(const std::string& errorDetails);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ItemResponse : public Response {
|
class ItemResponse : public Response {
|
||||||
|
|
|
@ -36,7 +36,6 @@ skin/search_results.css
|
||||||
templates/search_result.html
|
templates/search_result.html
|
||||||
templates/no_search_result.html
|
templates/no_search_result.html
|
||||||
templates/error.html
|
templates/error.html
|
||||||
templates/400.html
|
|
||||||
templates/500.html
|
templates/500.html
|
||||||
templates/index.html
|
templates/index.html
|
||||||
templates/suggestion.json
|
templates/suggestion.json
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta content="text/html;charset=UTF-8" http-equiv="content-type" />
|
|
||||||
<title>Invalid request</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Invalid request</h1>
|
|
||||||
{{#details}}
|
|
||||||
<p>
|
|
||||||
{{{p}}}
|
|
||||||
</p>
|
|
||||||
{{/details}}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Reference in New Issue