Last step of removing root from ContentResponse

This commit is contained in:
Veloman Yunkan 2023-11-29 18:32:18 +04:00
parent 6a651e04e5
commit db3b76247f
4 changed files with 7 additions and 11 deletions

View File

@ -661,7 +661,7 @@ MustacheData InternalServer::get_default_data() const
std::unique_ptr<Response> InternalServer::build_homepage(const RequestContext& request)
{
return ContentResponse::build(m_root, m_indexTemplateString, get_default_data(), "text/html; charset=utf-8");
return ContentResponse::build(m_indexTemplateString, get_default_data(), "text/html; charset=utf-8");
}
/**
@ -754,7 +754,7 @@ std::unique_ptr<Response> InternalServer::handle_viewer_settings(const RequestCo
{"enable_library_button", m_withLibraryButton ? "true" : "false" },
{"default_user_language", request.get_user_language() }
};
return ContentResponse::build(m_root, RESOURCE::templates::viewer_settings_js, data, "application/javascript; charset=utf-8");
return ContentResponse::build(RESOURCE::templates::viewer_settings_js, data, "application/javascript; charset=utf-8");
}
std::string InternalServer::getNoJSDownloadPageHTML(const std::string& bookId, const std::string& userLang) const
@ -871,7 +871,6 @@ std::unique_ptr<Response> InternalServer::handle_search(const RequestContext& re
if ( startsWith(request.get_url(), "/search/") ) {
if (request.get_url() == "/search/searchdescription.xml") {
return ContentResponse::build(
m_root,
RESOURCE::ft_opensearchdescription_xml,
get_default_data(),
"application/opensearchdescription+xml");
@ -1021,7 +1020,7 @@ std::unique_ptr<Response> InternalServer::handle_captured_external(const Request
auto data = get_default_data();
data.set("source", source);
return ContentResponse::build(m_root, RESOURCE::templates::captured_external_html, data, "text/html; charset=utf-8");
return ContentResponse::build(RESOURCE::templates::captured_external_html, data, "text/html; charset=utf-8");
}
std::unique_ptr<Response> InternalServer::handle_catch(const RequestContext& request)

View File

@ -75,7 +75,7 @@ std::unique_ptr<Response> InternalServer::handle_catalog(const RequestContext& r
}
if (url == "searchdescription.xml") {
auto response = ContentResponse::build(m_root, RESOURCE::opensearchdescription_xml, get_default_data(), "application/opensearchdescription+xml");
auto response = ContentResponse::build(RESOURCE::opensearchdescription_xml, get_default_data(), "application/opensearchdescription+xml");
return std::move(response);
}
@ -115,7 +115,7 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2(const RequestContext
return handle_catalog_v2_root(request);
} else if (url == "searchdescription.xml") {
const std::string endpoint_root = m_root + "/catalog/v2";
return ContentResponse::build(m_root,
return ContentResponse::build(
RESOURCE::catalog_v2_searchdescription_xml,
kainjow::mustache::object({{"endpoint_root", endpoint_root}}),
"application/opensearchdescription+xml"
@ -142,7 +142,6 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_root(const RequestCo
{
const std::string libraryId = getLibraryId();
return ContentResponse::build(
m_root,
RESOURCE::templates::catalog_v2_root_xml,
kainjow::mustache::object{
{"date", gen_date_str()},

View File

@ -158,7 +158,7 @@ std::string ContentResponseBlueprint::getMessage(const std::string& msgId) const
std::unique_ptr<ContentResponse> ContentResponseBlueprint::generateResponseObject() const
{
auto r = ContentResponse::build(m_root, m_template, m_data, m_mimeType);
auto r = ContentResponse::build(m_template, m_data, m_mimeType);
r->set_code(m_httpStatusCode);
return r;
}
@ -246,7 +246,7 @@ HTTP500Response::HTTP500Response(const std::string& root,
std::unique_ptr<ContentResponse> HTTP500Response::generateResponseObject() const
{
const std::string mimeType = "text/html;charset=utf-8";
auto r = ContentResponse::build(m_root, m_template, m_data, mimeType);
auto r = ContentResponse::build(m_template, m_data, mimeType);
r->set_code(m_httpStatusCode);
return r;
}
@ -404,7 +404,6 @@ std::unique_ptr<ContentResponse> ContentResponse::build(
}
std::unique_ptr<ContentResponse> ContentResponse::build(
const std::string& root,
const std::string& template_str,
kainjow::mustache::data data,
const std::string& mimetype)

View File

@ -97,7 +97,6 @@ class ContentResponse : public Response {
const std::string& mimetype);
static std::unique_ptr<ContentResponse> build(
const std::string& root,
const std::string& template_str,
kainjow::mustache::data data,
const std::string& mimetype);