cutelyst  4.5.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
staticmap.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2016-2017 Daniel Nicoletti <dantti12@gmail.com>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef STATICMAP_H
6 #define STATICMAP_H
7 
8 #include <Cutelyst/Context>
9 #include <Cutelyst/Plugin>
10 #include <vector>
11 
12 #include <QMimeDatabase>
13 #include <QString>
14 
15 struct MountPoint {
16  QString mountPoint;
17  QString path;
18  bool append;
19 };
20 
21 class Socket;
22 class StaticMap final : public Cutelyst::Plugin
23 {
24  Q_OBJECT
25 public:
27 
28  virtual bool setup(Cutelyst::Application *app) override;
29 
30  void addStaticMap(const QString &mountPoint, const QString &path, bool append);
31 
32 private:
33  void beforePrepareAction(Cutelyst::Context *c, bool *skipMethod);
34 
35  bool tryToServeFile(Cutelyst::Context *c, const MountPoint &mp, const QString &path);
36 
37  bool serveFile(Cutelyst::Context *c, const QString &filename);
38 
39  QMimeDatabase m_db;
40  std::vector<MountPoint> m_staticMaps;
41 };
42 
43 #endif // STATICMAP_H
The Cutelyst application.
Definition: application.h:66
The Cutelyst Context.
Definition: context.h:42
Base class for Cutelyst Plugins.
Definition: plugin.h:25
virtual bool setup(Cutelyst::Application *app) override
Definition: staticmap.cpp:26
Q_OBJECTQ_OBJECT
QObject * parent() const const