Skip to content

Commit

Permalink
fix: add QueryMapParam
Browse files Browse the repository at this point in the history
  • Loading branch information
artaasadi committed Sep 13, 2024
1 parent fe14934 commit 65c4023
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/httpserver/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 65c4023

Please sign in to comment.