Legacy /category/ URI
This commit is contained in:
parent
946a05c505
commit
c6e8e3f5e5
|
@ -42,6 +42,15 @@ func (b *Blog) BlogRoutes(r *mux.Router) {
|
||||||
r.HandleFunc("/archive", b.BlogArchive)
|
r.HandleFunc("/archive", b.BlogArchive)
|
||||||
r.HandleFunc("/tagged", b.Tagged)
|
r.HandleFunc("/tagged", b.Tagged)
|
||||||
r.HandleFunc("/tagged/{tag}", b.Tagged)
|
r.HandleFunc("/tagged/{tag}", b.Tagged)
|
||||||
|
r.HandleFunc("/category/{tag}", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
params := mux.Vars(r)
|
||||||
|
tag, ok := params["tag"]
|
||||||
|
if !ok {
|
||||||
|
b.NotFound(w, r, "Not Found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
b.Redirect(w, "/tagged/"+tag)
|
||||||
|
})
|
||||||
r.HandleFunc("/blog/entry/{fragment}", func(w http.ResponseWriter, r *http.Request) {
|
r.HandleFunc("/blog/entry/{fragment}", func(w http.ResponseWriter, r *http.Request) {
|
||||||
params := mux.Vars(r)
|
params := mux.Vars(r)
|
||||||
fragment, ok := params["fragment"]
|
fragment, ok := params["fragment"]
|
||||||
|
|
|
@ -26,7 +26,6 @@ func (b *Blog) FlashAndReload(w http.ResponseWriter, r *http.Request, message st
|
||||||
|
|
||||||
// Redirect sends an HTTP redirect response.
|
// Redirect sends an HTTP redirect response.
|
||||||
func (b *Blog) Redirect(w http.ResponseWriter, location string) {
|
func (b *Blog) Redirect(w http.ResponseWriter, location string) {
|
||||||
log.Error("Redirect: %s", location)
|
|
||||||
w.Header().Set("Location", location)
|
w.Header().Set("Location", location)
|
||||||
w.WriteHeader(http.StatusFound)
|
w.WriteHeader(http.StatusFound)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user