summaryrefslogtreecommitdiff
path: root/doc/articles/wiki/part3.go
diff options
context:
space:
mode:
Diffstat (limited to 'doc/articles/wiki/part3.go')
-rw-r--r--doc/articles/wiki/part3.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/doc/articles/wiki/part3.go b/doc/articles/wiki/part3.go
index 7fe4351af..174f3abcd 100644
--- a/doc/articles/wiki/part3.go
+++ b/doc/articles/wiki/part3.go
@@ -29,21 +29,19 @@ func loadPage(title string) (*Page, error) {
return &Page{Title: title, Body: body}, nil
}
-const lenPath = len("/view/")
-
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
t, _ := template.ParseFiles(tmpl + ".html")
t.Execute(w, p)
}
func viewHandler(w http.ResponseWriter, r *http.Request) {
- title := r.URL.Path[lenPath:]
+ title := r.URL.Path[len("/view/"):]
p, _ := loadPage(title)
renderTemplate(w, "view", p)
}
func editHandler(w http.ResponseWriter, r *http.Request) {
- title := r.URL.Path[lenPath:]
+ title := r.URL.Path[len("/edit/"):]
p, err := loadPage(title)
if err != nil {
p = &Page{Title: title}