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

Serve behind route prefix #283

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
SuperQ marked this conversation as resolved.
Show resolved Hide resolved
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 != "/" {
SuperQ marked this conversation as resolved.
Show resolved Hide resolved
if !h.routePrefixed && r.URL.Path != "/" {
http.NotFound(w, r)
return
}
Expand Down
Loading