From 2e513bb91e662f76cd5bee858296efc269861a37 Mon Sep 17 00:00:00 2001 From: lbenedar Date: Fri, 27 Feb 2026 12:52:18 +0300 Subject: [PATCH] ch2.5 --- main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 8cbbfb3..a267a1f 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,10 @@ package main import ( + "fmt" "log" "net/http" + "strconv" ) func home(w http.ResponseWriter, r *http.Request) { @@ -14,7 +16,12 @@ func home(w http.ResponseWriter, r *http.Request) { } func snippetView(w http.ResponseWriter, r *http.Request) { - w.Write([]byte("Display a specific snippet...")) + id, err := strconv.Atoi(r.URL.Query().Get("id")) + if err != nil || id < 1 { + http.NotFound(w, r) + return + } + fmt.Fprintf(w, "Display a specific snippet with ID %d...", id) } func snippetCreate(w http.ResponseWriter, r *http.Request) {