support runtime.ServeMux opts for grpc-gateway

This commit is contained in:
Ryan McGuire 2025-03-25 10:49:58 -04:00
parent adfedc9239
commit b44b6a331c
2 changed files with 4 additions and 2 deletions

View File

@ -18,7 +18,7 @@ func (a *appGRPCServer) registerServiceGatewayHandlers(ctx context.Context, serv
if len(service.GwRegistrationFuncs) < 1 {
return
} else if a.gatewayMux == nil {
a.gatewayMux = runtime.NewServeMux()
a.gatewayMux = runtime.NewServeMux(a.opts.GRPCGatewayOpts...)
}
ctx, span := a.tracer.Start(ctx, "appgrpc.init.prepare.service.gwHandlers", trace.WithAttributes(
@ -50,6 +50,7 @@ func (a *appGRPCServer) GetClientConn(ctx context.Context) *grpc.ClientConn {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())
panic(err)
}
return clientConn

View File

@ -19,7 +19,8 @@ type AppGRPC struct {
UnaryInterceptors []grpc.UnaryServerInterceptor
StreamInterceptors []grpc.StreamServerInterceptor
GRPCOpts []grpc.ServerOption
GRPCDialOpts []grpc.DialOption // Map ServerOptions to DialOpts for GRPC Gateway support
GRPCDialOpts []grpc.DialOption // Map ServerOptions to DialOpts for GRPC Gateway support
GRPCGatewayOpts []runtime.ServeMuxOption // Configure grpc-gateway ServeMux
GRPCDone <-chan error
gatewayMux *runtime.ServeMux
}