From db3b76247fc576d9c58fdc0cc1ab9968f49431df Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Wed, 29 Nov 2023 18:32:18 +0400 Subject: [PATCH] Last step of removing root from ContentResponse --- src/server/internalServer.cpp | 7 +++---- src/server/internalServer_catalog.cpp | 5 ++--- src/server/response.cpp | 5 ++--- src/server/response.h | 1 - 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index 4f4b986c6..7c710b488 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -661,7 +661,7 @@ MustacheData InternalServer::get_default_data() const std::unique_ptr 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 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 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 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 InternalServer::handle_catch(const RequestContext& request) diff --git a/src/server/internalServer_catalog.cpp b/src/server/internalServer_catalog.cpp index edb1b327c..a1ec11100 100644 --- a/src/server/internalServer_catalog.cpp +++ b/src/server/internalServer_catalog.cpp @@ -75,7 +75,7 @@ std::unique_ptr 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 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 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()}, diff --git a/src/server/response.cpp b/src/server/response.cpp index 04d158652..f4d1ea17c 100644 --- a/src/server/response.cpp +++ b/src/server/response.cpp @@ -158,7 +158,7 @@ std::string ContentResponseBlueprint::getMessage(const std::string& msgId) const std::unique_ptr 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 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::build( } std::unique_ptr ContentResponse::build( - const std::string& root, const std::string& template_str, kainjow::mustache::data data, const std::string& mimetype) diff --git a/src/server/response.h b/src/server/response.h index 7c3f2cf3f..f57ab9345 100644 --- a/src/server/response.h +++ b/src/server/response.h @@ -97,7 +97,6 @@ class ContentResponse : public Response { const std::string& mimetype); static std::unique_ptr build( - const std::string& root, const std::string& template_str, kainjow::mustache::data data, const std::string& mimetype);