![]() |
Stellarium
0.16.1
|
This class handles the API-specific requests and dispatches them to the correct RemoteControlServiceInterface implementation. More...
#include <APIController.hpp>
Public Member Functions | |
APIController (int prefixLength, QObject *parent=Q_NULLPTR) | |
Constructs an APIController. More... | |
void | update (double deltaTime) |
Should be called each frame from the main thread, like from StelModule::update. More... | |
virtual void | service (HttpRequest &request, HttpResponse &response) |
Handles an API-specific request. More... | |
void | registerService (RemoteControlServiceInterface *service) |
Registers a service with the APIController. More... | |
![]() | |
HttpRequestHandler (QObject *parent=Q_NULLPTR) | |
Constructor. More... | |
virtual | ~HttpRequestHandler () |
Destructor. More... | |
This class handles the API-specific requests and dispatches them to the correct RemoteControlServiceInterface implementation.
Services are registered using registerService(). To see the default services used, see the RequestHandler::RequestHandler constructor.
Definition at line 30 of file APIController.hpp.
APIController::APIController | ( | int | prefixLength, |
QObject * | parent = Q_NULLPTR |
||
) |
Constructs an APIController.
prefixLength | Determines how many characters to strip from the front of the request path |
parent | passed on to QObject constructor |
void APIController::registerService | ( | RemoteControlServiceInterface * | service | ) |
Registers a service with the APIController.
The RemoteControlServiceInterface::getPath() determines the request path of the service.
|
virtual |
Handles an API-specific request.
It finds out which RemoteControlServiceInterface to use depending on the service name (first part of path until slash). An error is returned for invalid requests. If a service was found, the request is passed on to its RemoteControlServiceInterface::get or RemoteControlServiceInterface::post method depending on the HTTP request type. If RemoteControlServiceInterface::isThreadSafe is false, these methods are called in the Stellarium main thread using QMetaObject::invokeMethod, otherwise they are directly executed in the current thread (HTTP worker thread).
Reimplemented from HttpRequestHandler.
void APIController::update | ( | double | deltaTime | ) |
Should be called each frame from the main thread, like from StelModule::update.
Passed on to each AbstractAPIService::update method for optional processing.