Skip to content

Commit

Permalink
Allow delete for > uint32 ids
Browse files Browse the repository at this point in the history
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:
https://github.com/gotify/plugin-api/blob/b0e2eca8e35526b0c02fdb5e2179a92bb8cb457f/plugin.go#L13-L14
  • Loading branch information
jmattheis committed Jul 1, 2020
1 parent 757fa17 commit d45e0da
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/internalutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package api

import (
"errors"
"math/bits"
"strconv"

"github.com/gin-gonic/gin"
)

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))
} else {
ctx.AbortWithError(400, errors.New("invalid id"))
Expand Down

0 comments on commit d45e0da

Please sign in to comment.