9#include <Cutelyst/Application>
10#include <Cutelyst/Request>
11#include <Cutelyst/Response>
15#include <QLoggingCategory>
17Q_LOGGING_CATEGORY(C_SERVER_SM,
"cutelyst.server.staticmap", QtWarningMsg)
34void 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});
45 return a.mountPoint.
size() < b.mountPoint.
size();
58 if (tryToServeFile(c, mp, path)) {
70 localPath = path.
mid(mp.mountPoint.
size());
77 QString absFilePath = dir.absoluteFilePath(localPath);
82 return serveFile(c, absFilePath);
90 res->setStatus(Response::NotModified);
94 auto file =
new QFile(filename);
96 qCDebug(C_SERVER_SM) <<
"Serving" << filename;
110 headers.
setHeader(
"Cache-Control"_ba,
"public"_ba);
115 qCWarning(C_SERVER_SM) <<
"Could not serve" << filename << file->errorString();
120#include "moc_staticmap.cpp"
The Cutelyst application.
void beforePrepareAction(Cutelyst::Context *c, bool *skipMethod)
Response * response() const noexcept
Base class for Cutelyst Plugins.
Headers headers() const noexcept
virtual bool setup(Cutelyst::Application *app) override
The Cutelyst namespace holds all public Cutelyst API.
bool exists() const const
QDateTime lastModified() const const
QMimeType mimeTypeForFile(const QFileInfo &fileInfo, QMimeDatabase::MatchMode mode) const const
bool isValid() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString mid(qsizetype position, qsizetype n) const const
QString & prepend(QChar ch)
QString & remove(QChar ch, Qt::CaseSensitivity cs)
qsizetype size() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const