Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kitgen enhancement: add Failer implementation when Response struct holds an error field #762

Closed
basvanbeek opened this issue Sep 14, 2018 · 0 comments

Comments

@basvanbeek
Copy link
Member

I'm currently working on a quick tutorial for OpenCensus involving scaffolding the app with kitgen.

I noticed the generated code does not add an implementation of the Failer interface when an error field for the Response struct is requested. It would be nice to add this feature so middleware can use the endpoint.Failer interface to identify business logic errors.

So a "hello" method like this:

type Service interface  {
    Hello(ctx context.Context, name string) (greeting string, err error)
}

would generate the following HelloResponse struct:

type HelloResponse struct {
  Greeting string
  Err      error
}

// Failed implements Failer
func (r HelloResponse) Failed() error { return r.Err }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants