diff --git a/pkg/httpserver/echo.go b/pkg/httpserver/echo.go index 6b9ddb5..dfe35d6 100644 --- a/pkg/httpserver/echo.go +++ b/pkg/httpserver/echo.go @@ -3,20 +3,18 @@ package httpserver import ( "context" "fmt" + "github.com/labstack/echo/v4" "os" "strconv" "strings" "github.com/kaytu-io/kaytu-util/pkg/metrics" - "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/jaeger" "go.opentelemetry.io/otel/propagation" sdktrace "go.opentelemetry.io/otel/sdk/trace" - "gopkg.in/go-playground/validator.v9" - "go.uber.org/zap" ) @@ -107,6 +105,17 @@ func QueryArrayParam(ctx echo.Context, paramName string) []string { return values } +func QueryMapParam(ctx echo.Context, paramName string) map[string][]string { + mapParam := make(map[string][]string) + for key, values := range ctx.QueryParams() { + if strings.HasPrefix(key, fmt.Sprintf("%s[", paramName)) && strings.HasSuffix(key, "]") { + tagKey := key[len(fmt.Sprintf("%s[", paramName)) : len(key)-1] + mapParam[tagKey] = values + } + } + return mapParam +} + func initTracer() (*sdktrace.TracerProvider, error) { exporter, err := jaeger.New(jaeger.WithAgentEndpoint(jaeger.WithAgentHost(agentHost))) if err != nil {