package main import ( "log" "net/http" "synlotto-website/handlers" services "synlotto-website/handlers/admin" "synlotto-website/helpers" "synlotto-website/middleware" "synlotto-website/models" "synlotto-website/storage" "github.com/gorilla/csrf" ) func main() { db := storage.InitDB("synlotto.db") models.SetDB(db) csrfMiddleware := csrf.Protect( []byte("abcdefghijklmnopqrstuvwx12345678"), // TodO: Make Global csrf.Secure(true), csrf.Path("/"), ) mux := http.NewServeMux() // Styling mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) mux.HandleFunc("/", handlers.Home(db)) mux.HandleFunc("/new", handlers.NewDraw) // ToDo: needs to be wrapped in admin auth mux.HandleFunc("/submit", handlers.Submit) // Result pages mux.HandleFunc("/results/thunderball", handlers.ResultsThunderball(db)) // Account Pages mux.HandleFunc("/login", middleware.Auth(false)(handlers.Login)) mux.HandleFunc("/logout", handlers.Logout) mux.HandleFunc("/signup", middleware.Auth(false)(handlers.Signup)) mux.HandleFunc("/account/tickets/add_ticket", handlers.AddTicket(db)) mux.HandleFunc("/account/tickets/my_tickets", handlers.GetMyTickets(db)) // Admin Pages mux.HandleFunc("/admin/triggers", services.AdminTriggersHandler(db)) log.Println("🌐 Running on http://localhost:8080") http.ListenAndServe(":8080", helpers.RateLimit(csrfMiddleware(mux))) }