mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Don't swallow marshalling errors in the Subsonic API
This commit is contained in:
parent
6d253225de
commit
0b2cf30096
1 changed files with 8 additions and 4 deletions
|
@ -286,20 +286,24 @@ func sendResponse(w http.ResponseWriter, r *http.Request, payload *responses.Sub
|
|||
p := req.Params(r)
|
||||
f, _ := p.String("f")
|
||||
var response []byte
|
||||
var err error
|
||||
switch f {
|
||||
case "json":
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
wrapper := &responses.JsonWrapper{Subsonic: *payload}
|
||||
response, _ = json.Marshal(wrapper)
|
||||
response, err = json.Marshal(wrapper)
|
||||
case "jsonp":
|
||||
w.Header().Set("Content-Type", "application/javascript")
|
||||
callback, _ := p.String("callback")
|
||||
wrapper := &responses.JsonWrapper{Subsonic: *payload}
|
||||
data, _ := json.Marshal(wrapper)
|
||||
response = []byte(fmt.Sprintf("%s(%s)", callback, data))
|
||||
response, err = json.Marshal(wrapper)
|
||||
response = []byte(fmt.Sprintf("%s(%s)", callback, response))
|
||||
default:
|
||||
w.Header().Set("Content-Type", "application/xml")
|
||||
response, _ = xml.Marshal(payload)
|
||||
response, err = xml.Marshal(payload)
|
||||
}
|
||||
if err != nil {
|
||||
log.Error(r.Context(), "Error marshalling response", "format", f, err)
|
||||
}
|
||||
if payload.Status == "ok" {
|
||||
if log.IsGreaterOrEqualTo(log.LevelTrace) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue