Renamed parameter validation method and removed "side effect"

This commit is contained in:
Deluan 2016-03-03 17:41:11 -05:00
parent c990073fc7
commit adfec414a1
4 changed files with 4 additions and 5 deletions

View File

@ -13,12 +13,11 @@ func (c *BaseAPIController) NewEmpty() responses.Subsonic {
return responses.Subsonic{Status: "ok", Version: beego.AppConfig.String("apiVersion")}
}
func (c *BaseAPIController) ValidateParameters(param string, msg string) string {
func (c *BaseAPIController) GetParameter(param string, msg string) string {
p := c.Input().Get(param)
if p == "" {
c.SendError(responses.ERROR_MISSING_PARAMETER, msg)
}
c.Data[param] = p
return p
}

View File

@ -21,7 +21,7 @@ func (c *GetCoverArtController) Prepare() {
}
func (c *GetCoverArtController) Get() {
id := c.ValidateParameters("id", "id parameter required")
id := c.GetParameter("id", "id parameter required")
mf, err := c.repo.Get(id)
if err != nil {

View File

@ -23,7 +23,7 @@ func (c *GetMusicDirectoryController) Prepare() {
}
func (c *GetMusicDirectoryController) Get() {
id := c.ValidateParameters("id", "id parameter required")
id := c.GetParameter("id", "id parameter required")
response := c.NewEmpty()

View File

@ -22,7 +22,7 @@ func (c *StreamController) Prepare() {
// For realtime transcoding, see : http://stackoverflow.com/questions/19292113/not-buffered-http-responsewritter-in-golang
func (c *StreamController) Get() {
id := c.ValidateParameters("id", "id parameter required")
id := c.GetParameter("id", "id parameter required")
mf, err := c.repo.Get(id)
if err != nil {