Use RSVP #15

Merged
Teajey merged 14 commits from rsvp-lib into main 2025-09-13 03:06:22 +12:00
1 changed files with 10 additions and 4 deletions
Showing only changes of commit d909adb6fa - Show all commits

View File

@ -4,6 +4,7 @@ import (
"encoding/gob"
"log"
"net/http"
"strings"
lishwist "lishwist/core"
"lishwist/http/api"
@ -13,6 +14,13 @@ import (
"lishwist/http/session"
)
func prefixMovedPermanently(before, after string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
suffix := strings.TrimPrefix(r.RequestURI, before)
http.Redirect(w, r, after+suffix, http.StatusMovedPermanently)
}
}
func main() {
gob.Register(&api.RegisterProps{})
gob.Register(&api.LoginProps{})
@ -50,10 +58,8 @@ func main() {
r.Private.HandleFunc("POST /{$}", routing.ExpectAppSession(routing.HomePost))
// Deprecated
r.Private.HandleFunc("GET /group/{groupReference}", routing.ExpectAppSession(routing.Group))
r.Private.HandleFunc("GET /list/{userReference}", routing.ExpectAppSession(routing.ForeignWishlist))
r.Public.HandleFunc("GET /group/{groupReference}", routing.PublicGroup)
r.Public.HandleFunc("GET /list/{userReference}", routing.PublicWishlist)
http.Handle("GET /group/{groupReference}", prefixMovedPermanently("/group/", "/groups/"))
http.Handle("GET /list/{userReference}", prefixMovedPermanently("/list/", "/lists/"))
http.Handle("/", r)