Move Verifier method to pkg-level func to accept *jwtauth.JwtAuth

This commit is contained in:
Peter Kieltyka 2017-07-06 18:09:09 -04:00
parent a5d0d75313
commit 6444fb9aef
5 changed files with 24 additions and 7 deletions

View file

@ -66,12 +66,14 @@ func NewWithParser(alg string, parser *jwt.Parser, signKey []byte, verifyKey []b
// be the generic `jwtauth.Authenticator` middleware or your own custom handler
// which checks the request context jwt token and error to prepare a custom
// http response.
func (ja *JwtAuth) Verifier(next http.Handler) http.Handler {
return ja.Verify("")(next)
func Verifier(ja *JwtAuth) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return Verify(ja, "")(next)
}
}
// TODO: explain
func (ja *JwtAuth) Verify(paramAliases ...string) func(http.Handler) http.Handler {
func Verify(ja *JwtAuth, paramAliases ...string) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
hfn := func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()