From 496946ef3ef784dc22081e4b325ad85c4564f027 Mon Sep 17 00:00:00 2001 From: monzarrugh Date: Thu, 23 Apr 2020 22:49:43 +0200 Subject: [PATCH 1/2] Added ctx.QueryMulti() QueryMulti returns all values for the query string parameter in the url. --- ctx.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ctx.go b/ctx.go index 143fd88723..4cef514105 100644 --- a/ctx.go +++ b/ctx.go @@ -600,6 +600,16 @@ func (ctx *Ctx) Query(key string) (value string) { return getString(ctx.Fasthttp.QueryArgs().Peek(key)) } +// QueryMulti returns all values for the query string parameter in the url. +func(ctx *Ctx) QueryMulti(key string) (values []string) { + valuesBytes := ctx.Fasthttp.QueryArgs().PeekMulti(key) + values := make([]string, len(valuesBytes)) + for i, v := range valuesBytes { + values[i] = getString(v) + } + return values +} + // Range returns a struct containing the type and a slice of ranges. func (ctx *Ctx) Range(size int) (rangeData Range, err error) { rangeStr := string(ctx.Fasthttp.Request.Header.Peek(HeaderRange)) From 11f34330347f853c6188d91c978dd3ae998dcfcb Mon Sep 17 00:00:00 2001 From: monzarrugh Date: Thu, 23 Apr 2020 23:01:47 +0200 Subject: [PATCH 2/2] Update ctx.go --- ctx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ctx.go b/ctx.go index 4cef514105..167df01f94 100644 --- a/ctx.go +++ b/ctx.go @@ -603,7 +603,7 @@ func (ctx *Ctx) Query(key string) (value string) { // QueryMulti returns all values for the query string parameter in the url. func(ctx *Ctx) QueryMulti(key string) (values []string) { valuesBytes := ctx.Fasthttp.QueryArgs().PeekMulti(key) - values := make([]string, len(valuesBytes)) + values = make([]string, len(valuesBytes)) for i, v := range valuesBytes { values[i] = getString(v) }