Skip to content

Commit

Permalink
Add argument to override serving landing page on root path, allowing …
Browse files Browse the repository at this point in the history
…for --web.external-url to be used with LandingPageHandler

Signed-off-by: kwilt <[email protected]>
  • Loading branch information
kwilt committed Jan 10, 2025
1 parent 8ecbde9 commit 29a8663
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions web/landing_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ type LandingLinks struct {
}

type LandingPageHandler struct {
landingPage []byte
landingPage []byte
routePrefixed bool
}

var (
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 29a8663

Please sign in to comment.