From 3ab09c4b2c249fe10dd3d35ef6b822d83c258de7 Mon Sep 17 00:00:00 2001 From: Deluan Date: Wed, 2 Mar 2016 23:58:35 -0500 Subject: [PATCH] Supporting "jsonp" format --- api/base_api_controller.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/base_api_controller.go b/api/base_api_controller.go index f213854bf..9dd5f6fef 100644 --- a/api/base_api_controller.go +++ b/api/base_api_controller.go @@ -29,11 +29,16 @@ func (c *BaseAPIController) SendError(errorCode int, message ...interface{}) { func (c *BaseAPIController) SendResponse(response responses.Subsonic) { f := c.GetString("f") - if f == "json" { + switch f { + case "json": w := &responses.JsonWrapper{Subsonic: response} c.Data["json"] = &w c.ServeJSON() - } else { + case "jsonp": + w := &responses.JsonWrapper{Subsonic: response} + c.Data["jsonp"] = &w + c.ServeJSONP() + default: c.Data["xml"] = &response c.ServeXML() }