mirror of
https://github.com/kataras/iris.git
synced 2025-02-09 02:34:55 +01:00
Add URLParamInt64 as requested by the community on chat
This commit is contained in:
parent
57ba8e89b5
commit
132021ec43
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
|
// ParamInt returns the int representation of the key's path named parameter's value
|
||||||
func (ctx *Context) ParamInt(key string) (int, error) {
|
func (ctx *Context) ParamInt(key string) (int, error) {
|
||||||
val, err := strconv.Atoi(ctx.Param(key))
|
return strconv.Atoi(ctx.Param(key))
|
||||||
return val, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// URLParam returns the get parameter from a request , if any
|
// URLParam returns the get parameter from a request , if any
|
||||||
|
@ -188,11 +187,16 @@ func (ctx *Context) URLParams() map[string]string {
|
||||||
return urlparams
|
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) {
|
func (ctx *Context) URLParamInt(key string) (int, error) {
|
||||||
return strconv.Atoi(ctx.URLParam(key))
|
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
|
// MethodString returns the HTTP Method
|
||||||
func (ctx *Context) MethodString() string {
|
func (ctx *Context) MethodString() string {
|
||||||
return utils.BytesToString(ctx.Method())
|
return utils.BytesToString(ctx.Method())
|
||||||
|
|
|
@ -18,6 +18,7 @@ type (
|
||||||
ParamInt(string) (int, error)
|
ParamInt(string) (int, error)
|
||||||
URLParam(string) string
|
URLParam(string) string
|
||||||
URLParamInt(string) (int, error)
|
URLParamInt(string) (int, error)
|
||||||
|
URLParamInt64(string) (int64, error)
|
||||||
URLParams() map[string]string
|
URLParams() map[string]string
|
||||||
MethodString() string
|
MethodString() string
|
||||||
HostString() string
|
HostString() string
|
||||||
|
|
Loading…
Reference in New Issue
Block a user