Skip to content

Commit

Permalink
404 anything that doesn't match routePrefix
Browse files Browse the repository at this point in the history
Signed-off-by: kwilt <[email protected]>
  • Loading branch information
kwilt committed Jan 11, 2025
1 parent 4ed0440 commit 15f17b6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions web/landing_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type LandingLinks struct {

type LandingPageHandler struct {
landingPage []byte
routePrefix string
}

var (
Expand Down Expand Up @@ -111,10 +112,15 @@ func NewLandingPage(c LandingConfig) (*LandingPageHandler, error) {

return &LandingPageHandler{
landingPage: buf.Bytes(),
routePrefix: c.RoutePrefix,
}, nil
}

func (h *LandingPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != h.routePrefix {
http.NotFound(w, r)
return
}
w.Header().Add("Content-Type", "text/html; charset=UTF-8")
w.Write(h.landingPage)
}

0 comments on commit 15f17b6

Please sign in to comment.