Created
October 9, 2015 23:03
-
-
Save kentquirk/60b46ed7a931194cf20b to your computer and use it in GitHub Desktop.
Check token Golang middleware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ChkTok is middleware that validates that the required | |
// security token is present. | |
func ChkTok(handler http.HandlerFunc) http.HandlerFunc { | |
return func(rw http.ResponseWriter, req *http.Request) { | |
sessionid := req.Header.Get(AUTHTOKEN) | |
if sessionid == "" { | |
util.WriteNewWebError(rw, http.StatusForbidden, "U-107", "x-anet-token is required.") | |
return | |
} | |
handler(rw, req) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment