Subsonic API: handle extensions

This commit is contained in:
emeric
2023-10-09 18:30:53 +02:00
parent caf558b6a0
commit 042cd54171
8 changed files with 120 additions and 71 deletions
+4 -20
View File
@@ -42,6 +42,7 @@
#include "entrypoints/MediaRetrieval.hpp"
#include "entrypoints/Playlists.hpp"
#include "entrypoints/Searching.hpp"
#include "entrypoints/System.hpp"
#include "entrypoints/UserManagement.hpp"
#include "ParameterParsing.hpp"
#include "ProtocolVersion.hpp"
@@ -119,29 +120,11 @@ namespace API::Subsonic
throw UserNotAuthorizedError{};
}
Response handlePingRequest(RequestContext& context)
{
return Response::createOkResponse(context.serverProtocolVersion);
}
Response handleGetLicenseRequest(RequestContext& context)
{
Response response{ Response::createOkResponse(context.serverProtocolVersion) };
Response::Node& licenseNode{ response.createNode("license") };
licenseNode.setAttribute("licenseExpires", "2025-09-03T14:46:43");
licenseNode.setAttribute("email", "foo@bar.com");
licenseNode.setAttribute("valid", true);
return response;
}
Response handleNotImplemented(RequestContext&)
{
throw NotImplementedGenericError{};
}
using RequestHandlerFunc = std::function<Response(RequestContext& context)>;
using CheckImplementedFunc = std::function<void()>;
struct RequestEntryPointInfo
@@ -154,8 +137,9 @@ namespace API::Subsonic
static const std::unordered_map<std::string_view, RequestEntryPointInfo> requestEntryPoints
{
// System
{"/ping", {handlePingRequest}},
{"/getLicense", {handleGetLicenseRequest}},
{"/ping", {handlePingRequest}},
{"/getLicense", {handleGetLicenseRequest}},
{"/getOpenSubsonicExtensions", {handleGetOpenSubsonicExtensions}},
// Browsing
{"/getMusicFolders", {handleGetMusicFoldersRequest}},