From b1518b0e09ae29be46b85f94a991b2a7485987ca Mon Sep 17 00:00:00 2001 From: H3ALY Date: Mon, 24 Mar 2025 22:00:51 +0000 Subject: [PATCH] ad better function handling --- main.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index f72245a..4114b2d 100644 --- a/main.go +++ b/main.go @@ -7,9 +7,22 @@ import ( ) func main() { - http.HandleFunc("/", handlers.Home) - http.HandleFunc("/new", handlers.NewDraw) - http.HandleFunc("/submit", handlers.Submit) + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/": + handlers.Home(w, r) + case "/new": + handlers.NewDraw(w, r) + case "/submit": + handlers.Submit(w, r) + case "/ticket": + handlers.NewTicket(w, r) + case "/submit-ticket": + handlers.SubmitTicket(w, r) + default: + http.NotFound(w, r) + } + }) log.Println("🚀 Lotto Tracker running on http://localhost:8080") log.Fatal(http.ListenAndServe(":8080", nil))