picgo/handler/index.go

29 lines
646 B
Go

package handler
import (
"github.com/gorilla/csrf"
"net/http"
"picgo/corelib"
)
func IndexHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
tmpData := map[string]interface{}{
csrf.TemplateTag: csrf.TemplateField(r),
}
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")
}
}