cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
server.h
1/*
2 * SPDX-FileCopyrightText: (C) 2016-2023 Daniel Nicoletti <dantti12@gmail.com>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#pragma once
6
7#include <Cutelyst/cutelyst_global.h>
8
9#include <QObject>
10
12
13namespace Cutelyst {
14
15class Application;
16class ServerPrivate;
59class CUTELYST_SERVER_EXPORT Server : public QObject
60{
61 Q_OBJECT
62 Q_DECLARE_PRIVATE(Server)
63public:
71 explicit Server(QObject *parent = nullptr);
72
76 virtual ~Server();
77
82 void parseCommandLine(const QStringList &args);
83
104 int exec(Cutelyst::Application *app = nullptr);
105
121 bool start(Cutelyst::Application *app = nullptr);
122
127 void stop();
128
134 Q_PROPERTY(QString application READ application WRITE setApplication NOTIFY changed)
135 void setApplication(const QString &application);
136 [[nodiscard]] QString application() const;
137
150 Q_PROPERTY(QString threads READ threads WRITE setThreads NOTIFY changed)
151 void setThreads(const QString &threads);
152 [[nodiscard]] QString threads() const;
153
159 Q_PROPERTY(QString processes READ processes WRITE setProcesses NOTIFY changed)
160 void setProcesses(const QString &process);
161 [[nodiscard]] QString processes() const;
162
167 Q_PROPERTY(QString chdir READ chdir WRITE setChdir NOTIFY changed)
168 void setChdir(const QString &chdir);
169 [[nodiscard]] QString chdir() const;
170
175 Q_PROPERTY(QStringList http_socket READ httpSocket WRITE setHttpSocket NOTIFY changed)
176 void setHttpSocket(const QStringList &httpSocket);
177 [[nodiscard]] QStringList httpSocket() const;
178
183 Q_PROPERTY(QStringList http2_socket READ http2Socket WRITE setHttp2Socket NOTIFY changed)
184 void setHttp2Socket(const QStringList &http2Socket);
185 [[nodiscard]] QStringList http2Socket() const;
186
191 Q_PROPERTY(quint32 http2_header_table_size READ http2HeaderTableSize WRITE
192 setHttp2HeaderTableSize NOTIFY changed)
193 void setHttp2HeaderTableSize(quint32 headerTableSize);
194 [[nodiscard]] quint32 http2HeaderTableSize() const;
195
201 Q_PROPERTY(bool upgrade_h2c READ upgradeH2c WRITE setUpgradeH2c NOTIFY changed)
202 void setUpgradeH2c(bool enable);
203 [[nodiscard]] bool upgradeH2c() const;
204
210 Q_PROPERTY(bool https_h2 READ httpsH2 WRITE setHttpsH2 NOTIFY changed)
211 void setHttpsH2(bool enable);
212 [[nodiscard]] bool httpsH2() const;
213
218 Q_PROPERTY(QStringList https_socket READ httpsSocket WRITE setHttpsSocket NOTIFY changed)
219 void setHttpsSocket(const QStringList &httpsSocket);
220 [[nodiscard]] QStringList httpsSocket() const;
221
226 Q_PROPERTY(QStringList fastcgi_socket READ fastcgiSocket WRITE setFastcgiSocket NOTIFY changed)
227 void setFastcgiSocket(const QStringList &fastcgiSocket);
228 [[nodiscard]] QStringList fastcgiSocket() const;
229
234 Q_PROPERTY(QString socket_access READ socketAccess WRITE setSocketAccess NOTIFY changed)
235 void setSocketAccess(const QString &socketAccess);
236 [[nodiscard]] QString socketAccess() const;
237
243 Q_PROPERTY(int socket_timeout READ socketTimeout WRITE setSocketTimeout NOTIFY changed)
244 void setSocketTimeout(int timeout);
245 [[nodiscard]] int socketTimeout() const;
246
251 Q_PROPERTY(QString chdir2 READ chdir2 WRITE setChdir2 NOTIFY changed)
252 void setChdir2(const QString &chdir2);
253 [[nodiscard]] QString chdir2() const;
254
272 Q_PROPERTY(QStringList ini READ ini WRITE setIni NOTIFY changed)
273 void setIni(const QStringList &files);
274 [[nodiscard]] QStringList ini() const;
275
299 Q_PROPERTY(QStringList json READ json WRITE setJson NOTIFY changed)
300 void setJson(const QStringList &files);
301 [[nodiscard]] QStringList json() const;
302
316 Q_PROPERTY(QStringList static_map READ staticMap WRITE setStaticMap NOTIFY changed)
317 void setStaticMap(const QStringList &staticMap);
318 [[nodiscard]] QStringList staticMap() const;
319
333 Q_PROPERTY(QStringList static_map2 READ staticMap2 WRITE setStaticMap2 NOTIFY changed)
334 void setStaticMap2(const QStringList &staticMap);
335 [[nodiscard]] QStringList staticMap2() const;
336
342 Q_PROPERTY(bool master READ master WRITE setMaster NOTIFY changed)
343 void setMaster(bool enable);
344 [[nodiscard]] bool master() const;
345
350 Q_PROPERTY(bool auto_reload READ autoReload WRITE setAutoReload NOTIFY changed)
351 void setAutoReload(bool enable);
352 [[nodiscard]] bool autoReload() const;
353
358 Q_PROPERTY(QStringList touch_reload READ touchReload WRITE setTouchReload NOTIFY changed)
359 void setTouchReload(const QStringList &files);
360 [[nodiscard]] QStringList touchReload() const;
361
369 Q_PROPERTY(int listen READ listenQueue WRITE setListenQueue NOTIFY changed)
370 void setListenQueue(int size);
371 [[nodiscard]] int listenQueue() const;
372
378 Q_PROPERTY(int buffer_size READ bufferSize WRITE setBufferSize NOTIFY changed)
379 void setBufferSize(int size);
380 [[nodiscard]] int bufferSize() const;
381
388 Q_PROPERTY(qint64 post_buffering READ postBuffering WRITE setPostBuffering NOTIFY changed)
389 void setPostBuffering(qint64 size);
390 [[nodiscard]] qint64 postBuffering() const;
391
397 Q_PROPERTY(qint64 post_buffering_bufsize READ postBufferingBufsize WRITE setPostBufferingBufsize
398 NOTIFY changed)
399 void setPostBufferingBufsize(qint64 size);
400 [[nodiscard]] qint64 postBufferingBufsize() const;
401
406 Q_PROPERTY(bool tcp_nodelay READ tcpNodelay WRITE setTcpNodelay NOTIFY changed)
407 void setTcpNodelay(bool enable);
408 [[nodiscard]] bool tcpNodelay() const;
409
414 Q_PROPERTY(bool so_keepalive READ soKeepalive WRITE setSoKeepalive NOTIFY changed)
415 void setSoKeepalive(bool enable);
416 [[nodiscard]] bool soKeepalive() const;
417
424 Q_PROPERTY(int socket_sndbuf READ socketSndbuf WRITE setSocketSndbuf NOTIFY changed)
425 void setSocketSndbuf(int value);
426 [[nodiscard]] int socketSndbuf() const;
427
434 Q_PROPERTY(int socket_rcvbuf READ socketRcvbuf WRITE setSocketRcvbuf NOTIFY changed)
435 void setSocketRcvbuf(int value);
436 [[nodiscard]] int socketRcvbuf() const;
437
442 Q_PROPERTY(
443 int websocket_max_size READ websocketMaxSize WRITE setWebsocketMaxSize NOTIFY changed)
444 void setWebsocketMaxSize(int value);
445 [[nodiscard]] int websocketMaxSize() const;
446
451 Q_PROPERTY(QString pidfile READ pidfile WRITE setPidfile NOTIFY changed)
452 void setPidfile(const QString &file);
453 [[nodiscard]] QString pidfile() const;
454
459 Q_PROPERTY(QString pidfile2 READ pidfile2 WRITE setPidfile2 NOTIFY changed)
460 void setPidfile2(const QString &file);
461 [[nodiscard]] QString pidfile2() const;
462
468 Q_PROPERTY(QString uid READ uid WRITE setUid NOTIFY changed)
469 void setUid(const QString &uid);
470 [[nodiscard]] QString uid() const;
471
477 Q_PROPERTY(QString gid READ gid WRITE setGid NOTIFY changed)
478 void setGid(const QString &gid);
479 [[nodiscard]] QString gid() const;
480
486 Q_PROPERTY(bool no_initgroups READ noInitgroups WRITE setNoInitgroups NOTIFY changed)
487 void setNoInitgroups(bool enable);
488 [[nodiscard]] bool noInitgroups() const;
489
495 Q_PROPERTY(QString chown_socket READ chownSocket WRITE setChownSocket NOTIFY changed)
496 void setChownSocket(const QString &chownSocket);
497 [[nodiscard]] QString chownSocket() const;
498
504 Q_PROPERTY(QString umask READ umask WRITE setUmask NOTIFY changed)
505 void setUmask(const QString &value);
506 [[nodiscard]] QString umask() const;
507
513 Q_PROPERTY(int cpu_affinity READ cpuAffinity WRITE setCpuAffinity NOTIFY changed)
514 void setCpuAffinity(int value);
515 [[nodiscard]] int cpuAffinity() const;
516
522 Q_PROPERTY(bool reuse_port READ reusePort WRITE setReusePort NOTIFY changed)
523 void setReusePort(bool enable);
524 [[nodiscard]] bool reusePort() const;
525
530 Q_PROPERTY(bool lazy READ lazy WRITE setLazy NOTIFY changed)
531 void setLazy(bool enable);
532 [[nodiscard]] bool lazy() const;
533
540 Q_PROPERTY(bool using_frontend_proxy READ usingFrontendProxy WRITE setUsingFrontendProxy NOTIFY
541 changed)
542 void setUsingFrontendProxy(bool enable);
543 [[nodiscard]] bool usingFrontendProxy() const;
544
549 [[nodiscard]] QVariantMap config() const noexcept;
550
551Q_SIGNALS:
555 void ready();
556
560 void stopped();
561
565 void changed();
566
570 void errorOccured(const QString &error);
571
572protected:
573 ServerPrivate *d_ptr;
574};
575
576} // namespace Cutelyst
The Cutelyst application.
Definition application.h:66
Implements a web server.
Definition server.h:60
The Cutelyst namespace holds all public Cutelyst API.