diff options
| author | Michael Stapelberg <stapelberg@debian.org> | 2013-12-03 09:43:15 +0100 |
|---|---|---|
| committer | Michael Stapelberg <stapelberg@debian.org> | 2013-12-03 09:43:15 +0100 |
| commit | 64d2a7c8945ba05af859901f5e248f1befdd8621 (patch) | |
| tree | 013fcb7e9e3296ecdda876012252c36bd6bcb063 /doc/articles/wiki/part3.go | |
| parent | b901efe83e212f0c34c769c079e41373da12d723 (diff) | |
| download | golang-64d2a7c8945ba05af859901f5e248f1befdd8621.tar.gz | |
Imported Upstream version 1.2upstream/1.2
Diffstat (limited to 'doc/articles/wiki/part3.go')
| -rw-r--r-- | doc/articles/wiki/part3.go | 6 |
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} |
