9 #ifndef CPPSERVER_HTTP_HTTP_SERVER_H
10 #define CPPSERVER_HTTP_HTTP_SERVER_H
14 #include "cache/filecache.h"
32 using TCPServer::TCPServer;
42 CppCommon::FileCache&
cache() noexcept {
return _cache; }
43 const CppCommon::FileCache&
cache() const noexcept {
return _cache; }
51 void AddStaticContent(
const CppCommon::Path& path,
const std::string& prefix =
"/",
const CppCommon::Timespan& timeout = CppCommon::Timespan::hours(1));
61 void Watchdog(
const CppCommon::UtcTimestamp& utc = CppCommon::UtcTimestamp()) { _cache.watchdog(utc); }
64 std::shared_ptr<Asio::TCPSession>
CreateSession(
const std::shared_ptr<Asio::TCPServer>& server)
override {
return std::make_shared<HTTPSession>(std::dynamic_pointer_cast<HTTPServer>(server)); }
68 CppCommon::FileCache _cache;
void AddStaticContent(const CppCommon::Path &path, const std::string &prefix="/", const CppCommon::Timespan &timeout=CppCommon::Timespan::hours(1))
Add static content cache.
HTTPServer & operator=(HTTPServer &&)=delete
void ClearStaticContent()
Clear static content cache.
CppCommon::FileCache & cache() noexcept
Get the static content cache.
HTTPServer(HTTPServer &&)=delete
const CppCommon::FileCache & cache() const noexcept
std::shared_ptr< Asio::TCPSession > CreateSession(const std::shared_ptr< Asio::TCPServer > &server) override
HTTPServer & operator=(const HTTPServer &)=delete
virtual ~HTTPServer()=default
HTTPServer(const HTTPServer &)=delete
void Watchdog(const CppCommon::UtcTimestamp &utc=CppCommon::UtcTimestamp())
Watchdog the static content cache.
void RemoveStaticContent(const CppCommon::Path &path)
Remove static content cache.
C++ Server project definitions.