diff options
Diffstat (limited to 'doc/codelab/wiki/final-template.go')
-rw-r--r-- | doc/codelab/wiki/final-template.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/doc/codelab/wiki/final-template.go b/doc/codelab/wiki/final-template.go index 06c9366ad..0bb133d3a 100644 --- a/doc/codelab/wiki/final-template.go +++ b/doc/codelab/wiki/final-template.go @@ -28,32 +28,32 @@ func loadPage(title string) (*page, os.Error) { const lenPath = len("/view/") -func editHandler(c *http.Conn, r *http.Request) { +func editHandler(w http.ResponseWriter, r *http.Request) { title := r.URL.Path[lenPath:] p, err := loadPage(title) if err != nil { p = &page{title: title} } - renderTemplate(c, "edit", p) + renderTemplate(w, "edit", p) } -func viewHandler(c *http.Conn, r *http.Request) { +func viewHandler(w http.ResponseWriter, r *http.Request) { title := r.URL.Path[lenPath:] p, _ := loadPage(title) - renderTemplate(c, "view", p) + renderTemplate(w, "view", p) } -func saveHandler(c *http.Conn, r *http.Request) { +func saveHandler(w http.ResponseWriter, r *http.Request) { title := r.URL.Path[lenPath:] body := r.FormValue("body") p := &page{title: title, body: []byte(body)} p.save() - http.Redirect(c, "/view/"+title, http.StatusFound) + http.Redirect(w, r, "/view/"+title, http.StatusFound) } -func renderTemplate(c *http.Conn, tmpl string, p *page) { +func renderTemplate(w http.ResponseWriter, tmpl string, p *page) { t, _ := template.ParseFile(tmpl+".html", nil) - t.Execute(p, c) + t.Execute(p, w) } func main() { |