2025-03-07 22:14:50 +01:00

65 lines
1.4 KiB
C++

#ifndef seafire__representation__metadata_hxx_
#define seafire__representation__metadata_hxx_
#include <seafire/protocol/media-type.hxx>
#include <seafire/protocol/rfc7232/entity-tag.hxx>
#include <seafire/representation/concepts.hxx>
#include <seafire/representation/representation.hxx>
#include <seafire/representation/traits.hxx>
#include <code/uri/uri.hxx>
#include <chrono>
#include <optional>
namespace seafire::representation
{
// etag
//
template<BasicRepresentation BR>
std::optional<protocol::rfc7232::entity_tag_t>
get_etag(BR const& rep)
{
using local_traits = traits::representation_traits<BR>;
if constexpr (local_traits::has_entity_tag_t)
return rep.etag();
return std::nullopt;
}
inline
std::optional<protocol::rfc7232::entity_tag_t>
get_etag(representation_t const& rep)
{
return rep.etag();
}
// last-modified
//
template<BasicRepresentation BR>
std::optional<std::chrono::system_clock::time_point>
get_last_modified(BR const& rep)
{
using local_traits = traits::representation_traits<BR>;
if constexpr (local_traits::has_last_modified)
return rep.last_modified();
return std::nullopt;
}
inline
std::optional<std::chrono::system_clock::time_point>
get_last_modified(representation_t const& rep)
{
return rep.last_modified();
}
} // namespace seafire::representation
#endif