mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-01 21:54:55 -04:00
Web API: /sdrangel/preset (GET) implementation
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "SWGAudioDevicesSelect.h"
|
||||
#include "SWGLocationInformation.h"
|
||||
#include "SWGDVSeralDevices.h"
|
||||
#include "SWGPresets.h"
|
||||
#include "SWGErrorResponse.h"
|
||||
|
||||
WebAPIRequestMapper::WebAPIRequestMapper(QObject* parent) :
|
||||
@@ -70,6 +71,8 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
|
||||
instanceLocationService(request, response);
|
||||
} else if (path == WebAPIAdapterInterface::instanceDVSerialURL) {
|
||||
instanceDVSerialService(request, response);
|
||||
} else if (path == WebAPIAdapterInterface::instancePresetURL) {
|
||||
instancePresetService(request, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -322,6 +325,29 @@ void WebAPIRequestMapper::instanceDVSerialService(qtwebapp::HttpRequest& request
|
||||
}
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::instancePresetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||
{
|
||||
Swagger::SWGPresets normalResponse;
|
||||
Swagger::SWGErrorResponse errorResponse;
|
||||
|
||||
if (request.getMethod() == "GET")
|
||||
{
|
||||
int status = m_adapter->instancePresetGet(normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status == 200) {
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(405,"Invalid HTTP method");
|
||||
response.write("Invalid HTTP method");
|
||||
}
|
||||
}
|
||||
|
||||
bool WebAPIRequestMapper::parseJsonBody(QString& jsonStr, qtwebapp::HttpResponse& response)
|
||||
{
|
||||
Swagger::SWGErrorResponse errorResponse;
|
||||
|
||||
Reference in New Issue
Block a user