Serve HTML files without .html extension in URLs

This commit is contained in:
Ian Gulliver
2025-12-30 10:43:58 -08:00
parent a247704523
commit 2b6fe0849e
2 changed files with 12 additions and 3 deletions

13
main.go
View File

@@ -91,6 +91,15 @@ func handleStatic(w http.ResponseWriter, r *http.Request) {
return
}
if !strings.Contains(name, ".") {
t := templates.Lookup(name + ".html")
if t != nil {
w.Header().Set("Content-Type", "text/html")
t.Execute(w, templateData())
return
}
}
http.ServeFile(w, r, filepath.Join("static", name))
}
@@ -266,8 +275,8 @@ func handleDonate(w http.ResponseWriter, r *http.Request) {
Quantity: stripe.Int64(1),
},
},
SuccessURL: stripe.String(os.Getenv("BASE_URL") + "/" + eventID + ".html?donated=1"),
CancelURL: stripe.String(os.Getenv("BASE_URL") + "/" + eventID + ".html"),
SuccessURL: stripe.String(os.Getenv("BASE_URL") + "/" + eventID + "?donated=1"),
CancelURL: stripe.String(os.Getenv("BASE_URL") + "/" + eventID),
Metadata: map[string]string{
"event_id": eventID,
"email": email,

View File

@@ -63,7 +63,7 @@
</div>
<h2>Events</h2>
<wa-card>
<a href="/afac26.html" class="event-card">
<a href="/afac26" class="event-card">
<img src="/afac26-logo.png" alt="Applause for a Cause">
<div class="event-info">
<p>Feb 7, 2026 · 6:30 PM</p>