Files
website/main.go
2025-03-25 15:12:56 +00:00

41 lines
1.0 KiB
Go

package main
import (
"log"
"net/http"
"synlotto-website/handlers"
"synlotto-website/helpers"
"synlotto-website/models"
"synlotto-website/storage"
"github.com/gorilla/csrf"
)
func main() {
db := storage.InitDB("synlotto.db")
models.SetDB(db)
csrfMiddleware := csrf.Protect(
[]byte("32-byte-long-auth-key-here"), // TodO: Make Global
csrf.Secure(false),
)
mux := http.NewServeMux()
mux.HandleFunc("/", handlers.Home(db))
mux.HandleFunc("/new", handlers.NewDraw)
mux.HandleFunc("/submit", handlers.Submit)
mux.HandleFunc("/ticket", handlers.NewTicket(db))
mux.HandleFunc("/tickets", handlers.ListTickets(db))
mux.HandleFunc("/submit-ticket", handlers.RequireAuth(handlers.SubmitTicket(db)))
mux.HandleFunc("/login", handlers.Login)
mux.HandleFunc("/logout", handlers.Logout)
mux.HandleFunc("/signup", handlers.Signup)
// Result pages
mux.HandleFunc("/results/thunderball", handlers.ResultsThunderball(db))
log.Println("🌐 Running on http://localhost:8080")
http.ListenAndServe(":8080", helpers.RateLimit(csrfMiddleware(mux)))
}