github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/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  }