CppServer  1.0.4.0
C++ Server Library
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"
15 #include "server/asio/ssl_server.h"
16 
17 namespace CppServer {
18 namespace HTTP {
19 
21 
30 {
31 public:
32  using SSLServer::SSLServer;
33 
34  HTTPSServer(const HTTPSServer&) = delete;
35  HTTPSServer(HTTPSServer&&) = delete;
36  virtual ~HTTPSServer() = default;
37 
38  HTTPSServer& operator=(const HTTPSServer&) = delete;
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 
63 protected:
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 
66 private:
67  // Static content cache
68  CppCommon::FileCache _cache;
69 };
70 
73 } // namespace HTTP
74 } // namespace CppServer
75 
76 #endif // CPPSERVER_HTTP_HTTPS_SERVER_H
void AddStaticContent(const CppCommon::Path &path, const std::string &prefix="/", const CppCommon::Timespan &timeout=CppCommon::Timespan::hours(1))
Add static content cache.
HTTPSServer & operator=(const HTTPSServer &)=delete
HTTPSServer(HTTPSServer &&)=delete
std::shared_ptr< Asio::SSLSession > CreateSession(const std::shared_ptr< Asio::SSLServer > &server) override
Definition: https_server.h:64
const CppCommon::FileCache & cache() const noexcept
Definition: https_server.h:43
void ClearStaticContent()
Clear static content cache.
Definition: https_server.h:58
HTTPSServer & operator=(HTTPSServer &&)=delete
virtual ~HTTPSServer()=default
void Watchdog(const CppCommon::UtcTimestamp &utc=CppCommon::UtcTimestamp())
Watchdog the static content cache.
Definition: https_server.h:61
void RemoveStaticContent(const CppCommon::Path &path)
Remove static content cache.
Definition: https_server.h:56
HTTPSServer(const HTTPSServer &)=delete
CppCommon::FileCache & cache() noexcept
Get the static content cache.
Definition: https_server.h:42
HTTPS session definition.
C++ Server project definitions.
Definition: asio.h:56
SSL server definition.