Skip to content

Commit

Permalink
feat(grpc-gateway-v2): default options should be in priority to all c…
Browse files Browse the repository at this point in the history
…aller's options.
  • Loading branch information
searKing committed Jun 20, 2024
1 parent ae3bfa7 commit b0ee707
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,12 @@ func (gw *Gateway) preServe(opts ...GatewayOption) {
if tlsConfig != nil {
creds := credentials.NewTLS(tlsConfig)
// for grpc server
gw.opt.grpcServerOpts.opts = append(gw.opt.grpcServerOpts.opts, grpc.Creds(creds))
gw.opt.grpcServerOpts.opts = append([]grpc.ServerOption{grpc.Creds(creds)}, gw.opt.grpcServerOpts.opts...)
// for grpc client to server
gw.opt.grpcClientDialOpts = append(gw.opt.grpcClientDialOpts, grpc.WithTransportCredentials(creds))
gw.opt.grpcClientDialOpts = append([]grpc.DialOption{grpc.WithTransportCredentials(creds)}, gw.opt.grpcClientDialOpts...)
} else {
// disables transport security
var opts []grpc.DialOption
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
gw.opt.grpcClientDialOpts = append(opts, gw.opt.grpcClientDialOpts...)
gw.opt.grpcClientDialOpts = append([]grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}, gw.opt.grpcClientDialOpts...)
}

gw.opt.srvMuxOpts = append(gw.opt.srvMuxOpts,
Expand Down

0 comments on commit b0ee707

Please sign in to comment.