cpp-qt5-qhttpengine-server.apirequest.h.mustache Maven / Gradle / Ivy
{{>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}}}{{#hasMore}}, {{/hasMore}}{{/pathParams}}{{/hasPathParams}});
{{/operation}}{{/operations}}
{{#operations}}{{#operation}}void {{nickname}}Response({{#returnType}}const {{{returnType}}}& res{{/returnType}});
{{/operation}}{{/operations}}
{{#operations}}{{#operation}}void {{nickname}}Error({{#returnType}}const {{{returnType}}}& 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}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{/operation}}{{/operations}}
private:
QMap requestHeaders;
QMap responseHeaders;
QHttpEngine::Socket *socket;
QSharedPointer<{{classname}}Handler> handler;
inline void writeResponseHeaders(){
QHttpEngine::Socket::HeaderMap resHeaders;
for(auto itr = responseHeaders.begin(); itr != responseHeaders.end(); ++itr) {
resHeaders.insert(itr.key().toUtf8(), itr.value().toUtf8());
}
socket->setHeaders(resHeaders);
socket->writeHeaders();
}
};
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
#endif // {{prefix}}_{{classname}}Request_H
© 2015 - 2024 Weber Informatics LLC | Privacy Policy