MCPcopy Create free account
hub / github.com/chronoxor/CppServer / AddStaticContent

Method AddStaticContent

source/server/http/https_server.cpp:16–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14namespace HTTP {
15
16void HTTPSServer::AddStaticContent(const CppCommon::Path& path, const std::string& prefix, const CppCommon::Timespan& timeout)
17{
18 auto hanlder = [](CppCommon::FileCache & cache, const std::string& key, const std::string& value, const CppCommon::Timespan& timespan)
19 {
20 auto response = HTTPResponse();
21 response.SetBegin(200);
22 response.SetContentType(CppCommon::Path(key).extension().string());
23 response.SetHeader("Cache-Control", CppCommon::format("max-age={}", timespan.seconds()));
24 response.SetBody(value);
25 return cache.insert(key, response.cache(), timespan);
26 };
27
28 cache().insert_path(path, prefix, timeout, hanlder);
29}
30
31} // namespace HTTP
32} // namespace CppServer

Callers

nothing calls this directly

Calls 3

HTTPResponseClass · 0.85
insertMethod · 0.80
stringMethod · 0.45

Tested by

no test coverage detected