code: func (a *authenticator) Validate(provider http.HandlerFunc) http.HandlerFunc {
  	return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
  		// Token may be accessed via cookie, or from authentication header
  		tokenString, errCode, err := a.getTokenStringFromRequest(req)
  		if err != nil {
  			a.formatter.Text(w, errCode, err.Error())
  			return
  		}
  		// Retrieve token object from raw string
  		token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
  			if _, ok := jwt.GetSigningMethod(token.Header["alg"].(string)).(*jwt.SigningMethodHMAC); !ok {
  				return nil, fmt.Errorf("error parsing token")
  			}
  			return []byte(signature), nil
  		})
  		if err != nil {
  			errStr := fmt.Sprintf("500 internal server error: %s", err)
  			a.formatter.Text(w, http.StatusInternalServerError, errStr)
  			return
  		}
  		// Validate token claims
  		if token.Claims != nil {
  			if err := token.Claims.Valid(); err != nil {
  				errStr := fmt.Sprintf("401 Unauthorized: %v", err)
  				a.formatter.Text(w, http.StatusUnauthorized, errStr)
  				return
  			}
  		}
  		// Validate token itself
  		if err := a.validateToken(token, req.URL.Path, req.Method); err != nil {
  			errStr := fmt.Sprintf("401 Unauthorized: %v", err)
  			a.formatter.Text(w, http.StatusUnauthorized, errStr)
  			return
  		}
  
  		provider.ServeHTTP(w, req)
  	})
  }
docs: // Validate the request