Cutelyst  2.1.0
wsgi.h
1 /*
2  * Copyright (C) 2016-2018 Daniel Nicoletti <dantti12@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef WSGI_H
19 #define WSGI_H
20 
21 #include <QObject>
22 
23 #include <Cutelyst/cutelyst_global.h>
24 
25 class QCoreApplication;
26 
27 namespace Cutelyst {
28 class Application;
29 }
30 
31 namespace CWSGI {
32 
33 class WSGIPrivate;
38 class CUTELYST_WSGI_EXPORT WSGI : public QObject
39 {
40  Q_OBJECT
41  Q_DECLARE_PRIVATE(WSGI)
42 public:
43  explicit WSGI(QObject *parent = nullptr);
44  virtual ~WSGI();
45 
46  void parseCommandLine(const QStringList &args);
47 
64  int exec(Cutelyst::Application *app = nullptr);
65 
78  bool start(Cutelyst::Application *app = nullptr);
79 
84  void stop();
85 
91  Q_PROPERTY(QString application READ application WRITE setApplication NOTIFY changed)
92  void setApplication(const QString &application);
93  QString application() const;
94 
99  Q_PROPERTY(QString threads READ threads WRITE setThreads NOTIFY changed)
100  void setThreads(const QString &threads);
101  QString threads() const;
102 
103 #ifdef Q_OS_UNIX
104 
108  Q_PROPERTY(QString processes READ processes WRITE setProcesses NOTIFY changed)
109  void setProcesses(const QString &process);
110  QString processes() const;
111 #endif
112 
117  Q_PROPERTY(QString chdir READ chdir WRITE setChdir NOTIFY changed)
118  void setChdir(const QString &chdir);
119  QString chdir() const;
120 
125  Q_PROPERTY(QStringList http_socket READ httpSocket WRITE setHttpSocket NOTIFY changed)
126  void setHttpSocket(const QStringList &httpSocket);
127  QStringList httpSocket() const;
128 
133  Q_PROPERTY(QStringList http2_socket READ http2Socket WRITE setHttp2Socket NOTIFY changed)
134  void setHttp2Socket(const QStringList &http2Socket);
135  QStringList http2Socket() const;
136 
141  Q_PROPERTY(quint32 http2_header_table_size READ http2HeaderTableSize WRITE setHttp2HeaderTableSize NOTIFY changed)
142  void setHttp2HeaderTableSize(quint32 headerTableSize);
143  quint32 http2HeaderTableSize() const;
144 
150  Q_PROPERTY(bool upgrade_h2c READ upgradeH2c WRITE setUpgradeH2c NOTIFY changed)
151  void setUpgradeH2c(bool enable);
152  bool upgradeH2c() const;
153 
159  Q_PROPERTY(bool https_h2 READ httpsH2 WRITE setHttpsH2 NOTIFY changed)
160  void setHttpsH2(bool enable);
161  bool httpsH2() const;
162 
167  Q_PROPERTY(QStringList https_socket READ httpsSocket WRITE setHttpsSocket NOTIFY changed)
168  void setHttpsSocket(const QStringList &httpsSocket);
169  QStringList httpsSocket() const;
170 
175  Q_PROPERTY(QStringList fastcgi_socket READ fastcgiSocket WRITE setFastcgiSocket NOTIFY changed)
176  void setFastcgiSocket(const QStringList &fastcgiSocket);
177  QStringList fastcgiSocket() const;
178 
183  Q_PROPERTY(QString socket_access READ socketAccess WRITE setSocketAccess NOTIFY changed)
184  void setSocketAccess(const QString &socketAccess);
185  QString socketAccess() const;
186 
191  Q_PROPERTY(int socket_timeout READ socketTimeout WRITE setSocketTimeout NOTIFY changed)
192  void setSocketTimeout(int timeout);
193  int socketTimeout() const;
194 
199  Q_PROPERTY(QString chdir2 READ chdir2 WRITE setChdir2 NOTIFY changed)
200  void setChdir2(const QString &chdir2);
201  QString chdir2() const;
202 
207  Q_PROPERTY(QStringList ini READ ini WRITE setIni NOTIFY changed)
208  void setIni(const QStringList &ini);
209  QStringList ini() const;
210 
215  Q_PROPERTY(QStringList json READ json WRITE setJson NOTIFY changed)
216  void setJson(const QStringList &files);
217  QStringList json() const;
218 
223  Q_PROPERTY(QStringList static_map READ staticMap WRITE setStaticMap NOTIFY changed)
224  void setStaticMap(const QStringList &staticMap);
225  QStringList staticMap() const;
226 
231  Q_PROPERTY(QStringList static_map2 READ staticMap2 WRITE setStaticMap2 NOTIFY changed)
232  void setStaticMap2(const QStringList &staticMap);
233  QStringList staticMap2() const;
234 
240  Q_PROPERTY(bool master READ master WRITE setMaster NOTIFY changed)
241  void setMaster(bool enable);
242  bool master() const;
243 
248  Q_PROPERTY(bool auto_reload READ autoReload WRITE setAutoReload NOTIFY changed)
249  void setAutoReload(bool enable);
250  bool autoReload() const;
251 
256  Q_PROPERTY(QStringList touch_reload READ touchReload WRITE setTouchReload NOTIFY changed)
257  void setTouchReload(const QStringList &files);
258  QStringList touchReload() const;
259 
264  Q_PROPERTY(qint64 buffer_size READ bufferSize WRITE setBufferSize NOTIFY changed)
265  void setBufferSize(qint64 size);
266  int bufferSize() const;
267 
273  Q_PROPERTY(qint64 post_buffering READ postBuffering WRITE setPostBuffering NOTIFY changed)
274  void setPostBuffering(qint64 size);
275  qint64 postBuffering() const;
276 
281  Q_PROPERTY(qint64 post_buffering_bufsize READ postBufferingBufsize WRITE setPostBufferingBufsize NOTIFY changed)
282  void setPostBufferingBufsize(qint64 size);
283  qint64 postBufferingBufsize() const;
284 
289  Q_PROPERTY(bool tcp_nodelay READ tcpNodelay WRITE setTcpNodelay NOTIFY changed)
290  void setTcpNodelay(bool enable);
291  bool tcpNodelay() const;
292 
297  Q_PROPERTY(bool so_keepalive READ soKeepalive WRITE setSoKeepalive NOTIFY changed)
298  void setSoKeepalive(bool enable);
299  bool soKeepalive() const;
300 
305  Q_PROPERTY(int socket_sndbuf READ socketSndbuf WRITE setSocketSndbuf NOTIFY changed)
306  void setSocketSndbuf(int value);
307  int socketSndbuf() const;
308 
313  Q_PROPERTY(int socket_rcvbuf READ socketRcvbuf WRITE setSocketRcvbuf NOTIFY changed)
314  void setSocketRcvbuf(int value);
315  int socketRcvbuf() const;
316 
321  Q_PROPERTY(int websocket_max_size READ websocketMaxSize WRITE setWebsocketMaxSize NOTIFY changed)
322  void setWebsocketMaxSize(int value);
323  int websocketMaxSize() const;
324 
329  Q_PROPERTY(QString pidfile READ pidfile WRITE setPidfile NOTIFY changed)
330  void setPidfile(const QString &file);
331  QString pidfile() const;
332 
337  Q_PROPERTY(QString pidfile2 READ pidfile2 WRITE setPidfile2 NOTIFY changed)
338  void setPidfile2(const QString &file);
339  QString pidfile2() const;
340 
341 #ifdef Q_OS_UNIX
342 
346  Q_PROPERTY(QString uid READ uid WRITE setUid NOTIFY changed)
347  void setUid(const QString &uid);
348  QString uid() const;
349 
354  Q_PROPERTY(QString gid READ gid WRITE setGid NOTIFY changed)
355  void setGid(const QString &gid);
356  QString gid() const;
357 
362  Q_PROPERTY(bool no_initgroups READ noInitgroups WRITE setNoInitgroups NOTIFY changed)
363  void setNoInitgroups(bool enable);
364  bool noInitgroups() const;
365 
370  Q_PROPERTY(QString chown_socket READ chownSocket WRITE setChownSocket NOTIFY changed)
371  void setChownSocket(const QString &chownSocket);
372  QString chownSocket() const;
373 
378  Q_PROPERTY(QString umask READ umask WRITE setUmask NOTIFY changed)
379  void setUmask(const QString &value);
380  QString umask() const;
381 
386  Q_PROPERTY(int cpu_affinity READ cpuAffinity WRITE setCpuAffinity NOTIFY changed)
387  void setCpuAffinity(int value);
388  int cpuAffinity() const;
389 #endif
390 
391 #ifdef Q_OS_LINUX
392 
396  Q_PROPERTY(bool reuse_port READ reusePort WRITE setReusePort NOTIFY changed)
397  void setReusePort(bool enable);
398  bool reusePort() const;
399 #endif
400 
405  Q_PROPERTY(bool lazy READ lazy WRITE setLazy NOTIFY changed)
406  void setLazy(bool enable);
407  bool lazy() const;
408 
409 Q_SIGNALS:
413  void ready();
414 
418  void stopped();
419 
420  void changed();
421 
422 protected:
423  WSGIPrivate *d_ptr;
424 };
425 
426 }
427 
428 #endif // WSGI_H
Definition: wsgi.h:31
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
Implements a WSGI server.
Definition: wsgi.h:38
The Cutelyst Application.
Definition: application.h:55