added authentication among other things. considered working at this point.
This commit is contained in:
@@ -1,17 +1,24 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
"synlotto-website/helpers"
|
||||
"synlotto-website/models"
|
||||
|
||||
"github.com/gorilla/csrf"
|
||||
)
|
||||
|
||||
func Home(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("✅ Home hit")
|
||||
|
||||
err := Tmpl.ExecuteTemplate(w, "layout", map[string]interface{}{
|
||||
"Page": "index",
|
||||
tmpl := template.Must(template.ParseFiles(
|
||||
"templates/layout.html",
|
||||
"templates/index.html",
|
||||
))
|
||||
|
||||
err := tmpl.ExecuteTemplate(w, "layout", map[string]interface{}{
|
||||
"Data": Draws,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -23,9 +30,15 @@ func Home(w http.ResponseWriter, r *http.Request) {
|
||||
func NewDraw(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("➡️ New draw form opened")
|
||||
|
||||
err := Tmpl.ExecuteTemplate(w, "layout", map[string]interface{}{
|
||||
"Page": "new_draw",
|
||||
"Data": nil,
|
||||
tmpl := template.Must(template.ParseFiles(
|
||||
"templates/layout.html",
|
||||
"templates/new_draw.html",
|
||||
))
|
||||
|
||||
err := tmpl.ExecuteTemplate(w, "layout", map[string]interface{}{
|
||||
"csrfField": csrf.TemplateField(r),
|
||||
"Page": "new_draw",
|
||||
"Data": nil,
|
||||
})
|
||||
if err != nil {
|
||||
log.Println("❌ Template error:", err)
|
||||
|
||||
Reference in New Issue
Block a user