Deduplication of OPDS MIME type strings

This commit is contained in:
Veloman Yunkan 2023-04-25 12:15:28 +04:00
parent 9bd2df2327
commit 1273570e01
1 changed files with 23 additions and 5 deletions

View File

@ -33,6 +33,24 @@
namespace kiwix {
namespace
{
enum OPDSResponseKind
{
OPDS_ENTRY,
OPDS_NAVIGATION_FEED,
OPDS_ACQUISITION_FEED
};
const std::string opdsMimeType[] = {
"application/atom+xml;type=entry;profile=opds-catalog",
"application/atom+xml;profile=opds-catalog;kind=navigation",
"application/atom+xml;profile=opds-catalog;kind=acquisition"
};
} // unnamed namespace
std::unique_ptr<Response> InternalServer::handle_catalog_v2(const RequestContext& request)
{
if (m_verbose.load()) {
@ -90,7 +108,7 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_root(const RequestCo
{"category_list_feed_id", gen_uuid(libraryId + "/categories")},
{"language_list_feed_id", gen_uuid(libraryId + "/languages")}
},
"application/atom+xml;profile=opds-catalog;kind=navigation"
opdsMimeType[OPDS_NAVIGATION_FEED]
);
}
@ -104,7 +122,7 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_entries(const Reques
return ContentResponse::build(
*this,
opdsFeed,
"application/atom+xml;profile=opds-catalog;kind=acquisition"
opdsMimeType[OPDS_ACQUISITION_FEED]
);
}
@ -124,7 +142,7 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_complete_entry(const
return ContentResponse::build(
*this,
opdsFeed,
"application/atom+xml;type=entry;profile=opds-catalog"
opdsMimeType[OPDS_ENTRY]
);
}
@ -136,7 +154,7 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_categories(const Req
return ContentResponse::build(
*this,
opdsDumper.categoriesOPDSFeed(),
"application/atom+xml;profile=opds-catalog;kind=navigation"
opdsMimeType[OPDS_NAVIGATION_FEED]
);
}
@ -148,7 +166,7 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_languages(const Requ
return ContentResponse::build(
*this,
opdsDumper.languagesOPDSFeed(),
"application/atom+xml;profile=opds-catalog;kind=navigation"
opdsMimeType[OPDS_NAVIGATION_FEED]
);
}