Use RSVP #15
14
http/main.go
14
http/main.go
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
lishwist "lishwist/core"
|
lishwist "lishwist/core"
|
||||||
"lishwist/http/api"
|
"lishwist/http/api"
|
||||||
|
|
@ -13,6 +14,13 @@ import (
|
||||||
"lishwist/http/session"
|
"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() {
|
func main() {
|
||||||
gob.Register(&api.RegisterProps{})
|
gob.Register(&api.RegisterProps{})
|
||||||
gob.Register(&api.LoginProps{})
|
gob.Register(&api.LoginProps{})
|
||||||
|
|
@ -50,10 +58,8 @@ func main() {
|
||||||
r.Private.HandleFunc("POST /{$}", routing.ExpectAppSession(routing.HomePost))
|
r.Private.HandleFunc("POST /{$}", routing.ExpectAppSession(routing.HomePost))
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
r.Private.HandleFunc("GET /group/{groupReference}", routing.ExpectAppSession(routing.Group))
|
http.Handle("GET /group/{groupReference}", prefixMovedPermanently("/group/", "/groups/"))
|
||||||
r.Private.HandleFunc("GET /list/{userReference}", routing.ExpectAppSession(routing.ForeignWishlist))
|
http.Handle("GET /list/{userReference}", prefixMovedPermanently("/list/", "/lists/"))
|
||||||
r.Public.HandleFunc("GET /group/{groupReference}", routing.PublicGroup)
|
|
||||||
r.Public.HandleFunc("GET /list/{userReference}", routing.PublicWishlist)
|
|
||||||
|
|
||||||
http.Handle("/", r)
|
http.Handle("/", r)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue