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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

routePrefixed override #283

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kwilt
Copy link

@kwilt kwilt commented Jan 10, 2025

This new parameter will allow for serving the landing page when using --web.external-url as an argument with many exporters.

I added this as it is needed for this pull request: prometheus/snmp_exporter#1335

So in practice it will look something like this:

landingConfig := web.LandingConfig{
        // config stuff goes here ...
		}
                                                                      // new parameter
		landingPage, err := web.NewLandingPage(landingConfig, *routePrefix != "")
		if err != nil {
			logger.Error("Error creating landing page", "err", err)
			os.Exit(1)
		}
		http.Handle(*routePrefix, landingPage)

…for --web.external-url to be used with LandingPageHandler

Signed-off-by: kwilt <kwilt@pm.me>
@@ -71,7 +72,7 @@ var (
landingPagecssContent string
)

func NewLandingPage(c LandingConfig) (*LandingPageHandler, error) {
func NewLandingPage(c LandingConfig, routePrefixed bool) (*LandingPageHandler, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a LandingConfig, it doesn't make sense to add another bool value here.

Also, rather than have a bool value, we can add a RoutePrefix string directly to the LandingConfig. If the RoutePrefix is "", we can default it to /.

…fix when provided

Signed-off-by: kwilt <kwilt@pm.me>
@kwilt
Copy link
Author

kwilt commented Jan 11, 2025

Okay, I think I've made the changes you requested

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

Successfully merging this pull request may close these issues.

2 participants