aboutsummaryrefslogtreecommitdiff
path: root/del.go
blob: a10612966ef08890f74fa9390fd1a30882857468 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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)
}