Introduced helper methods for parsing/biding request parameters

This commit is contained in:
Deluan
2016-03-07 14:13:01 -05:00
parent 91c660c746
commit 28bef732cf
8 changed files with 28 additions and 20 deletions
+3 -5
View File
@@ -27,7 +27,7 @@ func (c *GetAlbumListController) Prepare() {
}
func (c *GetAlbumListController) Get() {
typ := c.GetParameter("type", "Required string parameter 'type' is not present")
typ := c.RequiredParamString("type", "Required string parameter 'type' is not present")
qo, found := c.types[typ]
if !found {
@@ -35,10 +35,8 @@ func (c *GetAlbumListController) Get() {
c.SendError(responses.ERROR_GENERIC, "Not implemented!")
}
qo.Size = 10
c.Ctx.Input.Bind(&qo.Size, "size")
qo.Size = utils.MinInt(qo.Size, 500)
c.Ctx.Input.Bind(&qo.Offset, "offset")
qo.Size = utils.MinInt(c.ParamInt("size"), 500)
qo.Offset = c.ParamInt("offset")
albums, err := c.albumRepo.GetAll(qo)
if err != nil {