picgo/handler/index.go

29 lines
646 B
Go
Raw Normal View History

2024-07-11 21:25:58 +08:00
package handler
2024-07-12 20:32:33 +08:00
import (
2024-07-14 20:31:27 +08:00
"github.com/gorilla/csrf"
2024-07-12 20:32:33 +08:00
"net/http"
"picgo/corelib"
)
func IndexHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
2024-07-14 20:31:27 +08:00
tmpData := map[string]interface{}{
csrf.TemplateTag: csrf.TemplateField(r),
2024-07-12 20:32:33 +08:00
}
2024-07-14 20:31:27 +08:00
tmpData["Title"] = "Dashboard"
tmpData["Active"] = r.URL.Path
//data := struct {
// Title string
// Active string
// //csrfField string
//}{
// Title: "Dashboard",
// Active: r.URL.Path,
// //csrfField: string(csrf.TemplateField(r)),
//}
w.Header().Add("X-CSRF-Token", csrf.Token(r))
corelib.TemplateHandler(w, tmpData, "view/layout.html", "view/index.html")
2024-07-12 20:32:33 +08:00
}
}