20 #ifndef ABSTRACTAPISERVICE_HPP_ 21 #define ABSTRACTAPISERVICE_HPP_ 48 void setHeader(
const QByteArray& name,
const QByteArray& val);
50 void setHeader(
const QByteArray& name,
const int val);
52 void setStatus(
int status,
const QByteArray& text);
55 void setData(
const QByteArray& data);
67 QByteArray statusText;
68 QMap<QByteArray,QByteArray> headers;
69 QByteArray responseData;
75 static int metaTypeId;
76 static int parametersMetaTypeId;
94 AbstractAPIService(
const QByteArray& serviceName, QObject* parent = 0) : QObject(parent), m_serviceName(serviceName)
110 virtual bool supportsThreadedOperation()
const;
114 virtual void update(
double deltaTime);
153 QString wrapHtml(QString& text,
const QString& title)
const;
155 QByteArray m_serviceName;
void writeRequestError(const QByteArray &msg)
Sets the HTTP status to 400, and sets the response data to the message.
void writeJSON(const QJsonDocument &doc)
Sets the Content-Type to "application/json" and serializes the given document into JSON text format...
Thread-safe version of HttpResponse that can be passed around through QMetaObject::invokeMethod.
APIServiceResponse()
Constructs an invalid response.
void appendData(const QByteArray &data)
Appends to the current return data.
void setHeader(const QByteArray &name, const QByteArray &val)
Sets a specific HTTP header to the specified value.
AbstractAPIService(const QByteArray &serviceName, QObject *parent=0)
Abstract constructor. The service name is used by the APIController for request path mapping...
static const Qt::ConnectionType SERVICE_DEFAULT_INVOKETYPE
This defines the connection type QMetaObject::invokeMethod has to use inside a service: either Qt::Di...
Abstract base class for all Remote Control Plug-in service implementations.
QMultiMap< QByteArray, QByteArray > APIParameters
Defines the HTTP request parameters for the service.
void update(double deltaTime)
Should be called each frame from the main thread, like from StelModule::update.
void setData(const QByteArray &data)
Replaces the current return data.
QByteArray serviceName()
Returns the service name, used for request path mapping by the APIController.
This class handles the API-specific requests and dispatches them to the correct AbstractAPISerice imp...
void setStatus(int status, const QByteArray &text)
Sets the HTTP status type and status text.
This object represents a HTTP response, used to return something to the web client.