MCPcopy Create free account
hub / github.com/kataras/iris / URLParamInt

Method URLParamInt

context/context.go:1585–1595  ·  view source on GitHub ↗

URLParamInt returns the url query parameter as int value from a request, returns -1 and an error if parse failed or not found.

(name string)

Source from the content-addressed store, hash-verified

1583// URLParamInt returns the url query parameter as int value from a request,
1584// returns -1 and an error if parse failed or not found.
1585func (ctx *Context) URLParamInt(name string) (int, error) {
1586 if v := ctx.URLParam(name); v != "" {
1587 n, err := strconv.Atoi(v)
1588 if err != nil {
1589 return -1, err
1590 }
1591 return n, nil
1592 }
1593
1594 return -1, ErrNotFound
1595}
1596
1597// URLParamIntDefault returns the url query parameter as int value from a request,
1598// if not found or parse failed then "def" is returned.

Callers 1

URLParamIntDefaultMethod · 0.95

Calls 1

URLParamMethod · 0.95

Tested by

no test coverage detected