mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-01 21:54:55 -04:00
Web API: /sdrangel/preset (PUT) implementation
This commit is contained in:
@@ -154,6 +154,16 @@ public:
|
||||
Swagger::SWGErrorResponse& error __attribute__((unused)))
|
||||
{ return 501; }
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/preset (PUT) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int instancePresetPut(
|
||||
Swagger::SWGPresetTransfer& query __attribute__((unused)),
|
||||
Swagger::SWGPresetIdentifier& response __attribute__((unused)),
|
||||
Swagger::SWGErrorResponse& error __attribute__((unused)))
|
||||
{ return 501; }
|
||||
|
||||
static QString instanceSummaryURL;
|
||||
static QString instanceDevicesURL;
|
||||
static QString instanceChannelsURL;
|
||||
|
||||
@@ -362,6 +362,25 @@ void WebAPIRequestMapper::instancePresetService(qtwebapp::HttpRequest& request,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (request.getMethod() == "PUT")
|
||||
{
|
||||
Swagger::SWGPresetTransfer query;
|
||||
Swagger::SWGPresetIdentifier normalResponse;
|
||||
QString jsonStr = request.getBody();
|
||||
|
||||
if (parseJsonBody(jsonStr, response))
|
||||
{
|
||||
query.fromJson(jsonStr);
|
||||
int status = m_adapter->instancePresetPut(query, 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");
|
||||
|
||||
Reference in New Issue
Block a user