Skip to content

Commit

Permalink
Add RegisterWithOpts
Browse files Browse the repository at this point in the history
  • Loading branch information
LKaemmerling committed Nov 4, 2022
1 parent 384df28 commit aff0314
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ func (ps *FiberPrometheus) RegisterAtWithOpts(app *fiber.App, opts RegisterOpts,
}
ps.defaultURL = opts.URL
app.Get(ps.defaultURL, func(ctx *fiber.Ctx) error {
reqIP := ctx.IP()
reqIP := strings.ToLower(ctx.IP())
if len(reqIP) == 0 {
reqIP = ctx.Context().RemoteIP().String()
reqIP = strings.ToLower(ctx.Context().RemoteIP().String())
}
for _, ip := range opts.WhitelistedIPs {
if strings.ToLower(ip) == strings.ToLower(ctx.IP()) {
if strings.ToLower(ip) == reqIP {
err := adaptor.HTTPHandler(promhttp.Handler())(ctx)
if err != nil {
return err
Expand Down

0 comments on commit aff0314

Please sign in to comment.