Skip to content

Commit

Permalink
getting org slug from path param
Browse files Browse the repository at this point in the history
  • Loading branch information
vamshiaruru32 committed Apr 23, 2024
1 parent 91010d4 commit 5caad9f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strconv"
"time"

"github.com/go-chi/chi/v5"
"github.com/slok/go-http-metrics/metrics"
)

Expand All @@ -33,8 +34,8 @@ type Config struct {
// by default measuring inflights is enabled (`DisableMeasureInflight` is false).
DisableMeasureInflight bool
// UseChi will use the chi router to get the handler ID, by default it will be false.
UseChi bool
OrgSlugContextKey any
UseChi bool
OrgSlugPathParamKey string
}

func (c *Config) defaults() {
Expand Down Expand Up @@ -107,11 +108,7 @@ func (m Middleware) Measure(handlerID string, reporter Reporter, next func()) {
}

hid = reporter.URLPath()
orgSlug, ok := reporter.Context().Value(m.cfg.OrgSlugContextKey).(string)
if !ok {
orgSlug = ""
}

orgSlug := chi.URLParamFromCtx(reporter.Context(), m.cfg.OrgSlugPathParamKey)
props := metrics.HTTPReqProperties{
Service: m.cfg.Service,
ID: hid,
Expand Down

0 comments on commit 5caad9f

Please sign in to comment.