package main import ( "log" "net/http" "synlotto-website/handlers" "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() mux.HandleFunc("/", handlers.Home(db)) mux.HandleFunc("/new", handlers.NewDraw) // ToDo: needs to be wrapped in admin auth mux.HandleFunc("/submit", handlers.Submit) //mux.HandleFunc("/tickets", middleware.Auth(true)(handlers.ListTickets(db))) //mux.HandleFunc("/submit-ticket", helpers.AuthMiddleware(handlers.SubmitTicket(db))) mux.HandleFunc("/login", middleware.Auth(false)(handlers.Login)) mux.HandleFunc("/logout", handlers.Logout) mux.HandleFunc("/signup", middleware.Auth(false)(handlers.Signup)) // Result pages mux.HandleFunc("/results/thunderball", handlers.ResultsThunderball(db)) // Account Pages mux.HandleFunc("account/ticket/add_ticket", middleware.Auth(true)(handlers.NewTicket(db))) log.Println("🌐 Running on http://localhost:8080") http.ListenAndServe(":8080", helpers.RateLimit(csrfMiddleware(mux))) }