Selaa lähdekoodia

添加 QueryInt64

paddy 3 vuotta sitten
vanhempi
commit
c3da4497e5
1 muutettua tiedostoa jossa 7 lisäystä ja 0 poistoa
  1. 7 0
      context.go

+ 7 - 0
context.go

@@ -16,6 +16,7 @@ import (
 	"net/url"
 	"os"
 	"strings"
+	"strconv"
 	"time"
 
 	"github.com/gin-contrib/sse"
@@ -355,6 +356,12 @@ func (c *Context) Query(key string) string {
 	return value
 }
 
+func (c *Context) QueryInt64(key string) int64 {
+	value, _ := c.GetQuery(key)
+	i, _ := strconv.Atoi(value)
+	return int64(i)
+}
+
 // DefaultQuery returns the keyed url query value if it exists,
 // otherwise it returns the specified defaultValue string.
 // See: Query() and GetQuery() for further information.