9 #include <Cutelyst/Application> 10 #include <Cutelyst/Request> 11 #include <Cutelyst/Response> 15 #include <QLoggingCategory> 17 Q_LOGGING_CATEGORY(C_SERVER_SM,
"cutelyst.server.staticmap", QtWarningMsg)
34 void StaticMap::addStaticMap(
const QString &mountPoint,
const QString &path,
bool append)
41 qCInfo(C_SERVER_SM) <<
"added mapping for" << mp <<
"=>" << path;
43 m_staticMaps.
push_back({mp, path, append});
44 std::sort(m_staticMaps.begin(),
47 return a.mountPoint.
size() < b.mountPoint.size();
60 if (tryToServeFile(c, mp, path)) {
72 localPath = path.
mid(mp.mountPoint.
size());
79 QString absFilePath = dir.absoluteFilePath(localPath);
84 return serveFile(c, absFilePath);
92 res->setStatus(Response::NotModified);
96 auto file =
new QFile(filename);
98 qCDebug(C_SERVER_SM) <<
"Serving" << filename;
112 headers.
setHeader(
"Cache-Control"_ba,
"public"_ba);
117 qCWarning(C_SERVER_SM) <<
"Could not serve" << filename << file->errorString();
122 #include "moc_staticmap.cpp"
QString & prepend(QChar ch)
qsizetype size() const const
bool exists() const const
Headers headers() const noexcept
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
void beforePrepareAction(Cutelyst::Context *c, bool *skipMethod)
virtual bool setup(Cutelyst::Application *app) override
The Cutelyst namespace holds all public Cutelyst API.
QDateTime lastModified() const const
bool isValid() const const
QString & remove(QChar ch, Qt::CaseSensitivity cs)
QString mid(qsizetype position, qsizetype n) const const
Base class for Cutelyst Plugins.
The Cutelyst application.
Response * response() const noexcept