Adjust message api to use new app/client id

This commit is contained in:
Jannis Mattheis
2018-03-10 21:22:13 +01:00
committed by Jannis Mattheis
parent 433a83823b
commit 6dda2606d4
4 changed files with 91 additions and 58 deletions

15
api/internalutil.go Normal file
View File

@@ -0,0 +1,15 @@
package api
import (
"github.com/gin-gonic/gin"
"errors"
"strconv"
)
func withID(ctx *gin.Context, name string, f func(id uint)) {
if id, err := strconv.ParseUint(ctx.Param(name), 10, 32); err == nil {
f(uint(id));
} else {
ctx.AbortWithError(400, errors.New("invalid id"))
}
}