Allow delete for > uint32 ids
For ids uint is used, this is platform specific and either uint32
or uint64. The parsing for parameters in the api expected the ids to
have 32bit size.
I thought about changing all our ids to int64 but we sadly have one uint
usage in the plugin api:
b0e2eca8e3/plugin.go (L13-L14)
This commit is contained in:
parent
757fa17d26
commit
d45e0da6a8
|
|
@ -2,13 +2,14 @@ package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"math/bits"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func withID(ctx *gin.Context, name string, f func(id uint)) {
|
func withID(ctx *gin.Context, name string, f func(id uint)) {
|
||||||
if id, err := strconv.ParseUint(ctx.Param(name), 10, 32); err == nil {
|
if id, err := strconv.ParseUint(ctx.Param(name), 10, bits.UintSize); err == nil {
|
||||||
f(uint(id))
|
f(uint(id))
|
||||||
} else {
|
} else {
|
||||||
ctx.AbortWithError(400, errors.New("invalid id"))
|
ctx.AbortWithError(400, errors.New("invalid id"))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue