mirror of
https://github.com/rls-moe/nyx
synced 2024-11-14 22:12:24 +00:00
22 lines
404 B
Go
22 lines
404 B
Go
|
package middle
|
||
|
|
||
|
import (
|
||
|
"github.com/justinas/nosurf"
|
||
|
"github.com/pressly/chi/middleware"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func GetBaseCtx(r *http.Request) map[string]interface{} {
|
||
|
val := map[string]interface{}{
|
||
|
"Config": GetConfig(r),
|
||
|
"ReqID": middleware.GetReqID(r.Context()),
|
||
|
"CSRFToken": nosurf.Token(r),
|
||
|
}
|
||
|
|
||
|
return val
|
||
|
}
|
||
|
|
||
|
func CSRFProtect(next http.Handler) http.Handler {
|
||
|
return nosurf.New(next)
|
||
|
}
|