Commit 522b8fa

bryfry <bryon@fryer.io>
2025-07-17 21:45:05
init
Changed files (2)
go.mod
@@ -0,0 +1,3 @@
+module github.com/bryfry/buylater
+
+go 1.24.2
main.go
@@ -0,0 +1,37 @@
+package main
+
+import (
+	"log"
+	"net/http"
+)
+
+func home(w http.ResponseWriter, r *http.Request) {
+	w.Write([]byte("Landing Page"))
+}
+
+func buygoneView(w http.ResponseWriter, r *http.Request) {
+	w.Write([]byte("Display a specific BuyGone"))
+}
+
+func buygoneCreate(w http.ResponseWriter, r *http.Request) {
+	w.Write([]byte("Display a BuyGone creation form"))
+}
+
+func main() {
+	// Use the http.NewServeMux() function to initialize a new servemux, then
+	// register the home function as the handler for the "/" URL pattern.
+	mux := http.NewServeMux()
+	mux.HandleFunc("/", home)
+	mux.HandleFunc("/buygone/view", buygoneView)
+	mux.HandleFunc("/buygone/create", buygoneCreate)
+	// Print a log message to say that the server is starting.
+	log.Print("starting server on :4000")
+	// Use the http.ListenAndServe() function to start a new web server. We pass in
+	// two parameters: the TCP network address to listen on (in this case ":4000")
+	// and the servemux we just created. If http.ListenAndServe() returns an error
+	// we use the log.Fatal() function to log the error message and terminate the
+	// program. Note that any error returned by http.ListenAndServe() is always
+	// non-nil.
+	err := http.ListenAndServe(":4000", mux)
+	log.Fatal(err)
+}