diff options
Diffstat (limited to 'srv/src/http/csrf.go')
-rw-r--r-- | srv/src/http/csrf.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/srv/src/http/csrf.go b/srv/src/http/csrf.go index 1c80dee..7a45269 100644 --- a/srv/src/http/csrf.go +++ b/srv/src/http/csrf.go @@ -57,3 +57,22 @@ func checkCSRFMiddleware(h http.Handler) http.Handler { h.ServeHTTP(rw, r) }) } + +func (a *api) getCSRFTokenHandler() http.Handler { + + return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + + csrfTok, err := apiutil.GetCookie(r, csrfTokenCookieName, "") + + if err != nil { + apiutil.InternalServerError(rw, r, err) + return + } + + apiutil.JSONResult(rw, r, struct { + CSRFToken string + }{ + CSRFToken: csrfTok, + }) + }) +} |