Legacy /category/ URI

pull/4/head
Noah 2018-01-02 11:16:11 -08:00
parent 946a05c505
commit c6e8e3f5e5
2 changed files with 9 additions and 1 deletions

View File

@ -42,6 +42,15 @@ func (b *Blog) BlogRoutes(r *mux.Router) {
r.HandleFunc("/archive", b.BlogArchive)
r.HandleFunc("/tagged", 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) {
params := mux.Vars(r)
fragment, ok := params["fragment"]

View File

@ -26,7 +26,6 @@ func (b *Blog) FlashAndReload(w http.ResponseWriter, r *http.Request, message st
// Redirect sends an HTTP redirect response.
func (b *Blog) Redirect(w http.ResponseWriter, location string) {
log.Error("Redirect: %s", location)
w.Header().Set("Location", location)
w.WriteHeader(http.StatusFound)
}