From e73897553514fcb456e5f507dbb6f58f0de5f30a Mon Sep 17 00:00:00 2001 From: lbenedar Date: Fri, 27 Feb 2026 14:22:29 +0300 Subject: [PATCH] ch2.6 --- main.go => cmd/web/handlers.go | 12 ------------ cmd/web/main.go | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 12 deletions(-) rename main.go => cmd/web/handlers.go (72%) create mode 100644 cmd/web/main.go diff --git a/main.go b/cmd/web/handlers.go similarity index 72% rename from main.go rename to cmd/web/handlers.go index a267a1f..9de0073 100644 --- a/main.go +++ b/cmd/web/handlers.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "log" "net/http" "strconv" ) @@ -32,14 +31,3 @@ func snippetCreate(w http.ResponseWriter, r *http.Request) { } w.Write([]byte("Create a new snippet")) } - -func main() { - mux := http.NewServeMux() - mux.HandleFunc("/", home) - mux.HandleFunc("/snippet/view", snippetView) - mux.HandleFunc("/snippet/create", snippetCreate) - - log.Print("Starting server on :4000") - err := http.ListenAndServe(":4000", mux) - log.Fatal(err) -} diff --git a/cmd/web/main.go b/cmd/web/main.go new file mode 100644 index 0000000..b9d6763 --- /dev/null +++ b/cmd/web/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "log" + "net/http" +) + +func main() { + mux := http.NewServeMux() + mux.HandleFunc("/", home) + mux.HandleFunc("/snippet/view", snippetView) + mux.HandleFunc("/snippet/create", snippetCreate) + + log.Print("Starting server on :4000") + err := http.ListenAndServe(":4000", mux) + log.Fatal(err) +}