feat(subsonicapi): update Call method to return JSON string response

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan
2025-12-23 14:48:31 -05:00
parent 0ab34f1102
commit 658248f827
2 changed files with 5 additions and 5 deletions

View File

@@ -14,5 +14,5 @@ type SubsonicAPIService interface {
// The uri parameter should be the Subsonic API path without the server prefix,
// e.g., "getAlbumList2?type=random&size=10". The response is returned as raw JSON.
//nd:hostfunc
Call(ctx context.Context, uri string) (response []byte, err error)
Call(ctx context.Context, uri string) (responseJSON string, err error)
}

View File

@@ -11,8 +11,8 @@ import (
// SubsonicAPICallResponse is the response type for SubsonicAPI.Call.
type SubsonicAPICallResponse struct {
Response []byte `json:"response,omitempty"`
Error string `json:"error,omitempty"`
ResponseJSON string `json:"responseJSON,omitempty"`
Error string `json:"error,omitempty"`
}
// RegisterSubsonicAPIHostFunctions registers SubsonicAPI service host functions.
@@ -34,14 +34,14 @@ func newSubsonicAPICallHostFunction(service SubsonicAPIService) extism.HostFunct
}
// Call the service method
response, err := service.Call(ctx, uri)
responsejson, err := service.Call(ctx, uri)
if err != nil {
subsonicapiWriteError(p, stack, err)
return
}
// Write JSON response to plugin memory
resp := SubsonicAPICallResponse{
Response: response,
ResponseJSON: responsejson,
}
subsonicapiWriteResponse(p, stack, resp)
},