Files
storage-appliance/internal/http/template_helpers.go

21 lines
405 B
Go

package http
import (
"net/http"
)
// templateData adds CSRF token and other common data to template context
func templateData(r *http.Request, data map[string]interface{}) map[string]interface{} {
if data == nil {
data = make(map[string]interface{})
}
// Get CSRF token from cookie
if cookie, err := r.Cookie("csrf_token"); err == nil {
data["CSRFToken"] = cookie.Value
}
return data
}