diff --git a/context.go b/context.go index c24cb34a..3e76c6fe 100644 --- a/context.go +++ b/context.go @@ -170,8 +170,7 @@ func (ctx *Context) Param(key string) string { // ParamInt returns the int representation of the key's path named parameter's value func (ctx *Context) ParamInt(key string) (int, error) { - val, err := strconv.Atoi(ctx.Param(key)) - return val, err + return strconv.Atoi(ctx.Param(key)) } // URLParam returns the get parameter from a request , if any @@ -188,11 +187,16 @@ func (ctx *Context) URLParams() map[string]string { return urlparams } -// URLParamInt returns the get parameter int value from a request , if any +// URLParamInt returns the url query parameter as int value from a request , returns error on parse fail func (ctx *Context) URLParamInt(key string) (int, error) { return strconv.Atoi(ctx.URLParam(key)) } +// URLParamInt64 returns the url query parameter as int64 value from a request , returns error on parse fail +func (ctx *Context) URLParamInt64(key string) (int64, error) { + return strconv.ParseInt(ctx.Param(key), 10, 64) +} + // MethodString returns the HTTP Method func (ctx *Context) MethodString() string { return utils.BytesToString(ctx.Method()) diff --git a/context/context.go b/context/context.go index 83d4f5b9..29a77871 100644 --- a/context/context.go +++ b/context/context.go @@ -18,6 +18,7 @@ type ( ParamInt(string) (int, error) URLParam(string) string URLParamInt(string) (int, error) + URLParamInt64(string) (int64, error) URLParams() map[string]string MethodString() string HostString() string