added new handlers and workers

This commit is contained in:
Brad Rydzewski
2014-09-28 18:36:24 -07:00
parent 8993a71df2
commit 21f9aec808
45 changed files with 1522 additions and 3330 deletions

View File

@@ -3,8 +3,6 @@ package httputil
import (
"net/http"
"strings"
"code.google.com/p/xsrftoken"
)
// IsHttps is a helper function that evaluates the http.Request
@@ -105,26 +103,3 @@ func DelCookie(w http.ResponseWriter, r *http.Request, name string) {
http.SetCookie(w, &cookie)
}
// SetXsrf writes the cookie value.
func SetXsrf(w http.ResponseWriter, r *http.Request, token, login string) {
cookie := http.Cookie{
Name: "XSRF-TOKEN",
Value: xsrftoken.Generate(token, login, "/"),
Path: "/",
Domain: r.URL.Host,
HttpOnly: false,
Secure: IsHttps(r),
}
http.SetCookie(w, &cookie)
}
// CheckXsrf verifies the xsrf value.
func CheckXsrf(r *http.Request, token, login string) bool {
if r.Method == "GET" {
return true
}
return xsrftoken.Valid(
r.Header.Get("X-XSRF-TOKEN"), token, login, "/")
}