CppServer 1.0.5.0
C++ Server Library
Loading...
Searching...
No Matches
https_server.h
Go to the documentation of this file.
1
9#ifndef CPPSERVER_HTTP_HTTPS_SERVER_H
10#define CPPSERVER_HTTP_HTTPS_SERVER_H
11
12#include "https_session.h"
13
14#include "cache/filecache.h"
16
17namespace CppServer {
18namespace HTTP {
19
21
30{
31public:
32 using SSLServer::SSLServer;
33
34 HTTPSServer(const HTTPSServer&) = delete;
36 virtual ~HTTPSServer() = default;
37
40
42 CppCommon::FileCache& cache() noexcept { return _cache; }
43 const CppCommon::FileCache& cache() const noexcept { return _cache; }
44
46
51 void AddStaticContent(const CppCommon::Path& path, const std::string& prefix = "/", const CppCommon::Timespan& timeout = CppCommon::Timespan::hours(1));
53
56 void RemoveStaticContent(const CppCommon::Path& path) { _cache.remove_path(path); }
58 void ClearStaticContent() { _cache.clear(); }
59
61 void Watchdog(const CppCommon::UtcTimestamp& utc = CppCommon::UtcTimestamp()) { _cache.watchdog(utc); }
62
63protected:
64 std::shared_ptr<Asio::SSLSession> CreateSession(const std::shared_ptr<Asio::SSLServer>& server) override { return std::make_shared<HTTPSSession>(std::dynamic_pointer_cast<HTTPSServer>(server)); }
65
66private:
67 // Static content cache
68 CppCommon::FileCache _cache;
69};
70
73} // namespace HTTP
74} // namespace CppServer
75
76#endif // CPPSERVER_HTTP_HTTPS_SERVER_H
HTTPSServer & operator=(const HTTPSServer &)=delete
const CppCommon::FileCache & cache() const noexcept
void AddStaticContent(const CppCommon::Path &path, const std::string &prefix="/", const CppCommon::Timespan &timeout=CppCommon::Timespan::hours(1))
Add static content cache.
std::shared_ptr< Asio::SSLSession > CreateSession(const std::shared_ptr< Asio::SSLServer > &server) override
HTTPSServer(HTTPSServer &&)=delete
CppCommon::FileCache & cache() noexcept
Get the static content cache.
void ClearStaticContent()
Clear static content cache.
virtual ~HTTPSServer()=default
void Watchdog(const CppCommon::UtcTimestamp &utc=CppCommon::UtcTimestamp())
Watchdog the static content cache.
void RemoveStaticContent(const CppCommon::Path &path)
Remove static content cache.
HTTPSServer(const HTTPSServer &)=delete
HTTPSServer & operator=(HTTPSServer &&)=delete
HTTPS session definition.
C++ Server project definitions.
Definition asio.h:56
SSL server definition.