mirror of https://github.com/kiwix/libkiwix.git
Introduce `get_requested_format` helper
This commit is contained in:
parent
5d6b0ea96a
commit
e51a5b9ebc
|
@ -777,7 +777,7 @@ std::unique_ptr<Response> InternalServer::handle_search(const RequestContext& re
|
||||||
renderer.setProtocolPrefix(m_root + "/");
|
renderer.setProtocolPrefix(m_root + "/");
|
||||||
renderer.setSearchProtocolPrefix(m_root + "/search");
|
renderer.setSearchProtocolPrefix(m_root + "/search");
|
||||||
renderer.setPageLength(pageLength);
|
renderer.setPageLength(pageLength);
|
||||||
if (request.get_optional_param<std::string>("format", "") == "xml") {
|
if (request.get_requested_format() == "xml") {
|
||||||
return ContentResponse::build(*this, renderer.getXml(), "application/rss+xml; charset=utf-8",
|
return ContentResponse::build(*this, renderer.getXml(), "application/rss+xml; charset=utf-8",
|
||||||
/*isHomePage =*/false,
|
/*isHomePage =*/false,
|
||||||
/*raw =*/true);
|
/*raw =*/true);
|
||||||
|
|
|
@ -202,4 +202,9 @@ std::string RequestContext::get_user_language() const
|
||||||
return "en";
|
return "en";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string RequestContext::get_requested_format() const
|
||||||
|
{
|
||||||
|
return get_optional_param<std::string>("format", "html");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,7 @@ class RequestContext {
|
||||||
bool can_compress() const { return acceptEncodingGzip; }
|
bool can_compress() const { return acceptEncodingGzip; }
|
||||||
|
|
||||||
std::string get_user_language() const;
|
std::string get_user_language() const;
|
||||||
|
std::string get_requested_format() const;
|
||||||
|
|
||||||
private: // data
|
private: // data
|
||||||
std::string full_url;
|
std::string full_url;
|
||||||
|
|
Loading…
Reference in New Issue