From 29a866361dbf0ca5f4dbcf6870249c7a3ab5474e Mon Sep 17 00:00:00 2001 From: kwilt Date: Fri, 10 Jan 2025 15:25:45 -0600 Subject: [PATCH] Add argument to override serving landing page on root path, allowing for --web.external-url to be used with LandingPageHandler Signed-off-by: kwilt --- web/landing_page.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/landing_page.go b/web/landing_page.go index d417c15e..10fe5139 100644 --- a/web/landing_page.go +++ b/web/landing_page.go @@ -61,7 +61,8 @@ type LandingLinks struct { } type LandingPageHandler struct { - landingPage []byte + landingPage []byte + routePrefixed bool } var ( @@ -71,7 +72,7 @@ var ( landingPagecssContent string ) -func NewLandingPage(c LandingConfig) (*LandingPageHandler, error) { +func NewLandingPage(c LandingConfig, routePrefixed bool) (*LandingPageHandler, error) { var buf bytes.Buffer length := 0 @@ -101,12 +102,13 @@ func NewLandingPage(c LandingConfig) (*LandingPageHandler, error) { } return &LandingPageHandler{ - landingPage: buf.Bytes(), + landingPage: buf.Bytes(), + routePrefixed: routePrefixed, }, nil } func (h *LandingPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if r.URL.Path != "/" { + if !h.routePrefixed && r.URL.Path != "/" { http.NotFound(w, r) return }