SSX3LobbyServer/lib/http/utils.hpp

22 lines
709 B
C++

#pragma once
#include <boost/beast/http/message.hpp>
#include <chrono>
#include <base/types.hpp>
namespace base::http {
template <typename Clock>
inline std::string ImfDate(std::chrono::time_point<Clock> point) {
return std::format("{0:%a}, {0:%d %b %Y} {0:%T} GMT",
std::chrono::clock_cast<std::chrono::utc_clock>(std::chrono::time_point_cast<std::chrono::seconds>(point)));
}
// use this on a response please :)
template <class Body, class Fields>
constexpr void SetCommonResponseFields(beast::http::response<Body, Fields>& res) {
res.set(beast::http::field::date, ImfDate(std::chrono::utc_clock::now()));
res.set(beast::http::field::server, "Holgol");
}
} // namespace base::http