implement grpc gateway and addl handler support
This commit is contained in:
@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"github.com/rs/zerolog"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
|
@ -3,7 +3,7 @@ package opts
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
|
||||
@ -25,12 +25,14 @@ type AppGRPC struct {
|
||||
}
|
||||
|
||||
type GRPCService struct {
|
||||
Name string // Descriptive name of service
|
||||
Type *grpc.ServiceDesc // Type (from protoc generated code)
|
||||
Service any // Implementation of GRPCService.Type (ptr)
|
||||
GwRegistrationFuncs []func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error // Gateway regustration handler funcs
|
||||
Name string // Descriptive name of service
|
||||
Type *grpc.ServiceDesc // Type (from protoc generated code)
|
||||
Service any // Implementation of GRPCService.Type (ptr)
|
||||
GwRegistrationFuncs []GwRegistrationFunc // Gateway regustration handler funcs
|
||||
}
|
||||
|
||||
type GwRegistrationFunc func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error
|
||||
|
||||
func (a *AppGRPC) SetGatewayMux(mux *runtime.ServeMux) {
|
||||
a.gatewayMux = mux
|
||||
}
|
||||
|
@ -19,7 +19,9 @@ func (a *appGRPCServer) registerGRPCServices(ctx context.Context) {
|
||||
|
||||
for _, service := range a.opts.Services {
|
||||
a.registerGRPCService(ctx, service)
|
||||
a.registerServiceGatewayHandlers(ctx, service)
|
||||
if a.opts.EnableGRPCGateway {
|
||||
a.registerServiceGatewayHandlers(ctx, service)
|
||||
}
|
||||
}
|
||||
|
||||
span.SetStatus(codes.Ok, "")
|
||||
|
Reference in New Issue
Block a user