Use RSVP #15
14
http/main.go
14
http/main.go
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue