github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/examples/auto-configure/implementation/auth_impl.go (about)

     1  package implementation
     2  
     3  import "errors"
     4  
     5  type AuthImpl struct{}
     6  
     7  func (i *AuthImpl) KeyAuth(token string) (interface{}, error) {
     8  	if token != "example token" {
     9  		return nil, errors.New("Wrong token")
    10  	}
    11  	// if return nil, nil, will cause 401 error
    12  	return true, nil
    13  }