aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--handle.go9
-rw-r--r--main.go3
2 files changed, 11 insertions, 1 deletions
diff --git a/handle.go b/handle.go
index 20fa259..5059c1d 100644
--- a/handle.go
+++ b/handle.go
@@ -26,6 +26,10 @@ func (app *application) home(w http.ResponseWriter, r *http.Request) {
}
func (app *application) about(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path == "/about/" {
+ http.Redirect(w, r, "/about", http.StatusFound)
+ return
+ }
err := renderTemplate(w, "main/about", nil)
if err != nil {
app.serverError(w, err)
@@ -44,8 +48,11 @@ func (app *application) aggregate(w http.ResponseWriter, r *http.Request) {
func (app *application) post(w http.ResponseWriter, r *http.Request) {
path := strings.Split(r.URL.Path, "/")
- if path[2] == "" {
+ if r.URL.Path == "/blog" || r.URL.Path == "/projects" {
app.aggregate(w, r)
+ } else if path[2] == "" {
+ http.Redirect(w, r, strings.TrimSuffix(r.URL.Path, "/"), http.StatusFound)
+ return
} else {
post, err := app.readFile("html" + strings.TrimSuffix(r.URL.Path, "/") + ".tmpl.html")
if err != nil {
diff --git a/main.go b/main.go
index da578e4..6e9c95b 100644
--- a/main.go
+++ b/main.go
@@ -37,8 +37,11 @@ func main() {
fs := http.FileServer(http.Dir("./static"))
mux.Handle("/static/", http.StripPrefix("/static/", fs))
+ mux.HandleFunc("/projects", app.post)
mux.HandleFunc("/projects/", app.post)
+ mux.HandleFunc("/blog", app.post)
mux.HandleFunc("/blog/", app.post)
+ mux.HandleFunc("/about", app.about)
mux.HandleFunc("/about/", app.about)
mux.HandleFunc("/", app.home)