Skip to content

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

@basvanbeek

Description

@basvanbeek

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 }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions