code: func (om *Oauth2oauth_2_0Middleware) Handler(next http.Handler) http.Handler {
  	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  
  		var atscopestring string
  		var username string
  		accessToken := om.GetAccessToken(r)
  		if accessToken != "" {
  			//TODO: cache
  			oauthMgr := oauthservice.NewManager(r)
  			at, err := oauthMgr.GetAccessToken(accessToken)
  			if err != nil {
  				log.Error(err)
  				http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
  				return
  			}
  			if at == nil {
  				http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
  				return
  			}
  			atscopestring = at.Scope
  			username = at.Username
  		} else {
  			w.WriteHeader(401)
  			return
  		}
  		scopes := []string{}
  
  		contractID := mux.Vars(r)["contractId"]
  		contractMngr := contractdb.NewManager(r)
  		isParticipant, err := contractMngr.IsParticipant(contractID, username)
  		if err != nil {
  			log.Error(err)
  			http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
  			return
  		}
  		if isParticipant {
  			scopes = append(scopes, "contract:participant")
  			scopes = append(scopes, "contract:read")
  		}
  		log.Debug("Available scopes: ", scopes)
  		log.Debug("Atscopestring scope: ", atscopestring)
  
  		// check scopes
  		if !om.CheckScopes(scopes) {
  			w.WriteHeader(403)
  			return
  		}
  
  		next.ServeHTTP(w, r)
  	})
  }
docs: // Handler return HTTP handler representation of this middleware