mirror of
https://github.com/navidrome/navidrome.git
synced 2025-12-23 23:18:05 -05:00
feat(subsonicapi): update Call method to return JSON string response
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user