All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cpp-qt-qhttpengine-server.apirequest.h.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
{{>licenseInfo}}
#ifndef {{prefix}}_{{classname}}Request_H
#define {{prefix}}_{{classname}}Request_H

#include 
#include 
#include 
#include 
#include 

#include 
{{#imports}}{{{import}}}
{{/imports}}
#include "{{classname}}Handler.h"

{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}

class {{classname}}Request : public QObject
{
    Q_OBJECT

public:
    {{classname}}Request(QHttpEngine::Socket *s, QSharedPointer<{{classname}}Handler> handler);
    virtual ~{{classname}}Request();

    {{#operations}}{{#operation}}void {{nickname}}Request({{#hasPathParams}}{{#pathParams}}const QString& {{{paramName}}}{{^-last}}, {{/-last}}{{/pathParams}}{{/hasPathParams}});
    {{/operation}}{{/operations}}

    {{#operations}}{{#operation}}void {{nickname}}Response({{#returnType}}const {{{.}}}& res{{/returnType}});
    {{/operation}}{{/operations}}

    {{#operations}}{{#operation}}void {{nickname}}Error({{#returnType}}const {{{.}}}& res, {{/returnType}}QNetworkReply::NetworkError error_type, QString& error_str);
    {{/operation}}{{/operations}}

    void sendCustomResponse(QByteArray & res, QNetworkReply::NetworkError error_type);

    void sendCustomResponse(QIODevice *res, QNetworkReply::NetworkError error_type);

    QMap getRequestHeaders() const;

    QHttpEngine::Socket* getRawSocket();

    void setResponseHeaders(const QMultiMap& headers);

signals:
    {{#operations}}{{#operation}}void {{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
    {{/operation}}{{/operations}}

private:
    QMap requestHeaders;
    QMap responseHeaders;
    QHttpEngine::Socket  *socket;
    QSharedPointer<{{classname}}Handler> handler;

    inline void setSocketResponseHeaders(){
        QHttpEngine::Socket::HeaderMap resHeaders;
        for(auto itr = responseHeaders.begin(); itr != responseHeaders.end(); ++itr) {
            resHeaders.insert(itr.key().toUtf8(), itr.value().toUtf8());
        }
        socket->setHeaders(resHeaders);
    }
};

{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}

#endif // {{prefix}}_{{classname}}Request_H




© 2015 - 2024 Weber Informatics LLC | Privacy Policy