aboutsummaryrefslogtreecommitdiff
path: root/del.go
diff options
context:
space:
mode:
Diffstat (limited to 'del.go')
-rw-r--r--del.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/del.go b/del.go
new file mode 100644
index 0000000..a106129
--- /dev/null
+++ b/del.go
@@ -0,0 +1,17 @@
+package main
+
+import "net/http"
+
+func init() {
+ http.HandleFunc("/del/", delHandler)
+}
+
+func delHandler(w http.ResponseWriter, r *http.Request) {
+ title := r.URL.Path[len("/del/"):]
+ p := &Page{Title: title}
+ if err := p.del(); err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ http.Redirect(w, r, "/", http.StatusFound)
+}