Update frame work and workspace codebase
This commit is contained in:
20
internal/http/template_helpers.go
Normal file
20
internal/http/template_helpers.go
Normal file
@@ -0,0 +1,20 @@
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user