Skip to content

Commit

Permalink
make middleware private
Browse files Browse the repository at this point in the history
Signed-off-by: Ankur Srivastava <[email protected]>
  • Loading branch information
ansrivas committed Jul 4, 2020
1 parent decd2f4 commit 73d7d5f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import (
"github.com/valyala/fasthttp/fasthttpadaptor"
)

// FiberPrometheus ...
type FiberPrometheus struct {
counter *prometheus.CounterVec
histogram *prometheus.HistogramVec
DefaultURL string
defaultURL string
}

// New creates a new instance of FiberPrometheus middleware
Expand All @@ -38,7 +39,7 @@ func New(servicename string) *FiberPrometheus {
return &FiberPrometheus{
counter: counter,
histogram: histogram,
DefaultURL: "/metrics",
defaultURL: "/metrics",
}
}

Expand All @@ -49,8 +50,8 @@ func (ps *FiberPrometheus) handler(c *fiber.Ctx) {

// RegisterAt will register the prometheus handler at a given URL
func (ps *FiberPrometheus) RegisterAt(app *fiber.App, url string) {
ps.DefaultURL = url
app.Get(ps.DefaultURL, ps.handler)
ps.defaultURL = url
app.Get(ps.defaultURL, ps.handler)
}

// Middleware is the actual default middleware implementation
Expand All @@ -60,7 +61,7 @@ func (ps *FiberPrometheus) Middleware(ctx *fiber.Ctx) {
method := string(ctx.Fasthttp.Method())
path := string(ctx.Fasthttp.Path())

if path == ps.DefaultURL {
if path == ps.defaultURL {
ctx.Next()
return
}
Expand Down

0 comments on commit 73d7d5f

Please sign in to comment.