aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-02-18 12:16:35 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-02-18 12:16:35 +0100
commit6c26099e513f530977c954353449e675a5839737 (patch)
tree1ee14201dcd874b15010afd6fdabfafb86a510a1
parent5188e4fc1fd67b3bb2b20939eda8e7a7b1ac0281 (diff)
Combine files
-rw-r--r--assets.go8
-rw-r--r--handler.go13
-rw-r--r--save.go17
3 files changed, 13 insertions, 25 deletions
diff --git a/assets.go b/assets.go
deleted file mode 100644
index 0905228..0000000
--- a/assets.go
+++ /dev/null
@@ -1,8 +0,0 @@
-package main
-
-import "net/http"
-
-func init() {
- http.Handle("/css/", http.FileServer(http.Dir("assets")))
- http.Handle("/fonts/", http.FileServer(http.Dir("assets")))
-}
diff --git a/handler.go b/handler.go
index 04d6d94..369da40 100644
--- a/handler.go
+++ b/handler.go
@@ -7,10 +7,13 @@ import (
)
func init() {
+ http.Handle("/css/", http.FileServer(http.Dir("assets")))
+ http.Handle("/fonts/", http.FileServer(http.Dir("assets")))
http.HandleFunc("/index", indexHandler)
http.HandleFunc("/view/", viewHandler)
http.HandleFunc("/edit/", editHandler)
http.HandleFunc("/del/", delHandler)
+ http.HandleFunc("/save/", saveHandler)
http.HandleFunc("/", homeHandler)
}
@@ -62,6 +65,16 @@ func delHandler(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/", http.StatusFound)
}
+func saveHandler(w http.ResponseWriter, r *http.Request) {
+ title := r.URL.Path[len("/save/"):]
+ p := &Page{Title: title, Body: []byte(r.FormValue("body"))}
+ if err := p.save(); err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ http.Redirect(w, r, "/view/"+title, http.StatusFound)
+}
+
func homeHandler(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/view/Home", http.StatusFound)
}
diff --git a/save.go b/save.go
deleted file mode 100644
index 68ac700..0000000
--- a/save.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package main
-
-import "net/http"
-
-func init() {
- http.HandleFunc("/save/", saveHandler)
-}
-
-func saveHandler(w http.ResponseWriter, r *http.Request) {
- title := r.URL.Path[len("/save/"):]
- p := &Page{Title: title, Body: []byte(r.FormValue("body"))}
- if err := p.save(); err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
- http.Redirect(w, r, "/view/"+title, http.StatusFound)
-}