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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime.WithForwardResponseOption compile error #1607

Closed
zhangjie2012 opened this issue Aug 21, 2020 · 3 comments
Closed

runtime.WithForwardResponseOption compile error #1607

zhangjie2012 opened this issue Aug 21, 2020 · 3 comments

Comments

@zhangjie2012
Copy link

馃悰 Bug Report

use runtime.NewServeMux with runtime.WithForwardResponseOption compile throw:

cannot use myFilter (type func(context.Context, http.ResponseWriter, protoreflect.ProtoMessage) error) as type func(context.Context, http.ResponseWriter, protoiface.MessageV1) error in argument to "github.com/grpc-ecosystem/grpc-gateway/runtime".WithForwardResponseOption

source code:

func myFilter(ctx context.Context, w http.ResponseWriter, resp proto.Message) error {
    return nil
}
    gwMux := runtime.NewServeMux(
        // runtime.WithIncomingHeaderMatcher(func(key string) (string, bool) {
        //  return key, true
        // }),
        // runtime.WithOutgoingHeaderMatcher(func(key string) (string, bool) {
        //  return key, true
        // }),
        runtime.WithForwardResponseOption(myFilter),
    )

Environment

  • github.com/grpc-ecosystem/grpc-gateway v1.14.7
  • go version go1.14.7 darwin/amd64
@johanbrandhorst
Copy link
Collaborator

Hi Jerry, this is a simple function signature mismatch, probably because you imported the incorrect version of the protobuf package. Maybe I could help you sort this out on our support channel on gophers slack? Join #grpc-gateway on https://invite.slack.golangbridge.org/.

@zhangjie2012
Copy link
Author

My project used google.golang.org/protobuf/proto. gateway code used github.com/golang/protobuf/proto.

My emacs auto import package. Why gateway not consistent.

@johanbrandhorst
Copy link
Collaborator

You need to use the v2 release to use the new go protobuf stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants