diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index 3926957..bb223e6 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -70,7 +70,9 @@ func (app *application) snippetView(w http.ResponseWriter, r *http.Request) { } func (app *application) snippetCreate(w http.ResponseWriter, r *http.Request) { - w.Write([]byte("Display the form for creating a new snippet...")) + data := app.newTemplateData(r) + + app.render(w, http.StatusOK, "create.tmpl", data) } func (app *application) snippetCreatePost(w http.ResponseWriter, r *http.Request) { @@ -83,5 +85,5 @@ func (app *application) snippetCreatePost(w http.ResponseWriter, r *http.Request app.serverError(w, err) return } - http.Redirect(w, r, fmt.Sprintf("/snippet/view?id=%d", id), http.StatusSeeOther) + http.Redirect(w, r, fmt.Sprintf("/snippet/view/%d", id), http.StatusSeeOther) } diff --git a/ui/html/pages/create.tmpl b/ui/html/pages/create.tmpl new file mode 100644 index 0000000..e55507c --- /dev/null +++ b/ui/html/pages/create.tmpl @@ -0,0 +1,23 @@ +{{define "title"}}Create a New Snippet{{end}} + +{{define "main"}} +
+{{end}} \ No newline at end of file diff --git a/ui/html/partials/nav.tmpl b/ui/html/partials/nav.tmpl index ee7efd3..de6ebf0 100644 --- a/ui/html/partials/nav.tmpl +++ b/ui/html/partials/nav.tmpl @@ -1,5 +1,6 @@ {{define "nav"}} {{end}} \ No newline at end of file