Implemented common parameter validation

This commit is contained in:
Deluan
2016-03-03 14:14:15 -05:00
parent 053f4b72ba
commit 18b784f494
5 changed files with 18 additions and 12 deletions
+2 -7
View File
@@ -6,7 +6,6 @@ import (
"github.com/deluan/gosonic/domain"
"github.com/deluan/gosonic/utils"
"github.com/karlkfi/inject"
"mime"
)
type GetMusicDirectoryController struct {
@@ -23,11 +22,7 @@ func (c *GetMusicDirectoryController) Prepare() {
}
func (c *GetMusicDirectoryController) Get() {
id := c.Input().Get("id")
if id == "" {
c.SendError(responses.ERROR_MISSING_PARAMETER, "id parameter required")
}
id := c.ValidateParameters("id", "id parameter required")
response := c.NewEmpty()
@@ -83,7 +78,7 @@ func (c *GetMusicDirectoryController) buildAlbumDir(al *domain.Album, tracks []d
if mf.HasCoverArt {
dir.Child[i].CoverArt = mf.Id
}
dir.Child[i].ContentType = mime.TypeByExtension("." + mf.Suffix)
dir.Child[i].ContentType = mf.ContentType()
}
return dir
}