mirror of
https://github.com/kataras/iris.git
synced 2025-12-20 03:17:04 +00:00
Add URLParamInt64 as requested by the community on chat
This commit is contained in:
10
context.go
10
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())
|
||||
|
||||
Reference in New Issue
Block a user