~yerinalexey/gobin

185fc2d53cfdbfdd4058e180c58b052973829f1b — Alexey Yerin 11 months ago 1cb80e4
feat: save public field
1 files changed, 2 insertions(+), 1 deletions(-)

M main.go
M main.go => main.go +2 -1
@@ 68,9 68,10 @@ func main() {

	r.HandleFunc("/new", func(w http.ResponseWriter, req *http.Request) {
		contents := req.FormValue("contents")
		public := req.FormValue("public") == "on"

		var id int64
		err := pool.QueryRow(context.Background(), "insert into pastes (contents) values ($1) returning id", contents).Scan(&id)
		err := pool.QueryRow(context.Background(), "insert into pastes (contents, public) values ($1, $2) returning id", contents, public).Scan(&id)

		if err != nil {
			// Not Fatalf because nobody wants server to crash when database