Closed sysmat closed 1 year ago
Hey @sysmat I tried to reproduce this on my end, but it seems to be working just fine:
package main
import (
"github.com/ansrivas/fiberprometheus/v2"
"github.com/gofiber/fiber/v2"
)
func main() {
app := fiber.New()
prometheus := fiberprometheus.New("my_server")
prometheus.RegisterAt(app, "/metrics", func(c *fiber.Ctx) error {
return fiber.ErrUnauthorized
})
app.Use(prometheus.Middleware)
app.Listen(":3000")
}
And then I invoked it like this:
✦ ❯ curl -v http://localhost:3000/metrics
* Trying 127.0.0.1:3000...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET /metrics HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/8.0.1
> Accept: */*
>
< HTTP/1.1 401 Unauthorized <--------------------------------------------
< Date: Fri, 16 Jun 2023 14:35:20 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 12
<
* Connection #0 to host localhost left intact
Unauthorized
prometheus.RegisterAt(app, "/metrics", func(c *fiber.Ctx) error {
return fiber.ErrUnauthorized
})