Stellarium 0.15.2
List of all members | Public Member Functions | Friends
APIServiceResponse Struct Reference

Thread-safe version of HttpResponse that can be passed around through QMetaObject::invokeMethod. More...

#include <AbstractAPIService.hpp>

Public Member Functions

 APIServiceResponse ()
 Constructs an invalid response. More...
 
void setHeader (const QByteArray &name, const QByteArray &val)
 Sets a specific HTTP header to the specified value. More...
 
void setHeader (const QByteArray &name, const int val)
 Shortcut for int header values. More...
 
void setStatus (int status, const QByteArray &text)
 Sets the HTTP status type and status text. More...
 
void setData (const QByteArray &data)
 Replaces the current return data. More...
 
void appendData (const QByteArray &data)
 Appends to the current return data. More...
 
void writeRequestError (const QByteArray &msg)
 Sets the HTTP status to 400, and sets the response data to the message. More...
 
void writeJSON (const QJsonDocument &doc)
 Sets the Content-Type to "application/json" and serializes the given document into JSON text format. More...
 

Friends

class APIController
 

Detailed Description

Thread-safe version of HttpResponse that can be passed around through QMetaObject::invokeMethod.

It contains the data that will be sent back to the client in the HTTP thread, when control returns to the APIController.

Definition at line 38 of file AbstractAPIService.hpp.

Constructor & Destructor Documentation

APIServiceResponse::APIServiceResponse ( )
inline

Constructs an invalid response.

Definition at line 42 of file AbstractAPIService.hpp.

Member Function Documentation

void APIServiceResponse::appendData ( const QByteArray &  data)

Appends to the current return data.

void APIServiceResponse::setData ( const QByteArray &  data)

Replaces the current return data.

void APIServiceResponse::setHeader ( const QByteArray &  name,
const QByteArray &  val 
)

Sets a specific HTTP header to the specified value.

void APIServiceResponse::setHeader ( const QByteArray &  name,
const int  val 
)

Shortcut for int header values.

void APIServiceResponse::setStatus ( int  status,
const QByteArray &  text 
)

Sets the HTTP status type and status text.

void APIServiceResponse::writeJSON ( const QJsonDocument &  doc)

Sets the Content-Type to "application/json" and serializes the given document into JSON text format.

void APIServiceResponse::writeRequestError ( const QByteArray &  msg)

Sets the HTTP status to 400, and sets the response data to the message.


The documentation for this struct was generated from the following file: