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) +}