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

Method URLParamSlice

context/context.go:1528–1556  ·  view source on GitHub ↗

URLParamSlice a shortcut of ctx.Request().URL.Query()[name]. Like `URLParam` but it returns all values instead of a single string separated by commas. Returns the values of a url query of the given "name" as string slice, e.g. ?names=john&names=doe&names=kataras and ?names=john,doe,kataras will retu

(name string)

Source from the content-addressed store, hash-verified

1526//
1527// See `URLParamsSorted` for sorted values.
1528func (ctx *Context) URLParamSlice(name string) []string {
1529 values := ctx.getQuery()[name]
1530 n := len(values)
1531 if n == 0 {
1532 return values
1533 }
1534
1535 var sep string
1536 if sepPtr := ctx.app.ConfigurationReadOnly().GetURLParamSeparator(); sepPtr != nil {
1537 sep = *sepPtr
1538 }
1539
1540 normalizedValues := make([]string, 0, n)
1541 for _, v := range values {
1542 if v == "" {
1543 continue
1544 }
1545
1546 if sep != "" {
1547 values := strings.Split(v, sep)
1548 normalizedValues = append(normalizedValues, values...)
1549 continue
1550 }
1551
1552 normalizedValues = append(normalizedValues, v)
1553 }
1554
1555 return normalizedValues
1556}
1557
1558// URLParamTrim returns the url query parameter with trailing white spaces removed from a request.
1559func (ctx *Context) URLParamTrim(name string) string {

Callers 1

mainFunction · 0.80

Calls 3

getQueryMethod · 0.95
GetURLParamSeparatorMethod · 0.65
ConfigurationReadOnlyMethod · 0.65

Tested by

no test coverage detected