Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 [Bug]: Monitor middleware ignores custom settings if default title is used. #2019

Closed
3 tasks done
gaby opened this issue Aug 17, 2022 · 4 comments 路 Fixed by #2024
Closed
3 tasks done

馃悰 [Bug]: Monitor middleware ignores custom settings if default title is used. #2019

gaby opened this issue Aug 17, 2022 · 4 comments 路 Fixed by #2024

Comments

@gaby
Copy link
Member

gaby commented Aug 17, 2022

Bug Description

When using the monitor middleware I noticed that if I don't change the title or refresh rate the other custom settings don't get applied.

The bug is on this line: https://github.com/gofiber/fiber/blob/master/middleware/monitor/config.go#L99

Where if title or refresh rate are the Default Values everything else gets ignored in the else.

How to Reproduce

Run code

Expected Behavior

Custom settings should be applied regardless of title/refresh rate.

Fiber Version

v2.36.0

Code Snippet (optional) (Bug, Font/Chart URLs are ignored)

package main

import (
	"log"

	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/middleware/monitor"
)

func main() {
	app := fiber.New()

	app.Get("/metrics", monitor.New(monitor.Config{
	    FontURL: "blah/blah.css",
	    ChartJsURL: "blah/blah.js",
    }))

	log.Fatal(app.Listen(":3000"))
}

Code Snippet (Working, Font/Chart URLs get applied)

package main

import (
	"log"

	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/middleware/monitor"
)

func main() {
	app := fiber.New()

	app.Get("/metrics", monitor.New(monitor.Config{
	    Title: "MyService Metrics Page",
	    FontURL: "blah/blah.css",
	    ChartJsURL: "blah/blah.js",
    }))

	log.Fatal(app.Listen(":3000"))
}

This bug doesn't show up in monitor_test.go, because the test is changing the Title to "New + DefaultTitle".

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have checked for existing issues that describe my problem prior to opening this one.
  • I understand that improperly formatted bug reports may be closed without explanation.
@gaby gaby changed the title 馃悰 [Bug]: Monitor middleware ignores custom settings if title is not changed 馃悰 [Bug]: Monitor middleware ignores custom settings if default title is used. Aug 17, 2022
@ReneWerner87
Copy link
Member

@jfcg can you support here
initial code is comming from #1898

@jfcg
Copy link
Contributor

jfcg commented Aug 19, 2022

I was just coding a cleaner solution to this :D

@gaby
Copy link
Member Author

gaby commented Aug 19, 2022

I was just coding a cleaner solution to this :D

One thing I wish it supported is passing files paths instead of urls.

Right now I have copies of the js/css files in my container and I expose them via app.Static('/static', './static').

Ideally the monitor config supported file based resources and used those in the html imports.

@jfcg
Copy link
Contributor

jfcg commented Aug 19, 2022

I think we need to unexport default config as discussed in #1898

#1956 introduced the bug with the three new fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants