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

Method URLParamInt32Default

context/context.go:1610–1621  ·  view source on GitHub ↗

URLParamInt32Default returns the url query parameter as int32 value from a request, if not found or parse failed then "def" is returned.

(name string, def int32)

Source from the content-addressed store, hash-verified

1608// URLParamInt32Default returns the url query parameter as int32 value from a request,
1609// if not found or parse failed then "def" is returned.
1610func (ctx *Context) URLParamInt32Default(name string, def int32) int32 {
1611 if v := ctx.URLParam(name); v != "" {
1612 n, err := strconv.ParseInt(v, 10, 32)
1613 if err != nil {
1614 return def
1615 }
1616
1617 return int32(n)
1618 }
1619
1620 return def
1621}
1622
1623// URLParamInt64 returns the url query parameter as int64 value from a request,
1624// returns -1 and an error if parse failed or not found.

Callers 1

Calls 1

URLParamMethod · 0.95

Tested by

no test coverage detected