fix: grpc gateway interceptors (#3767)

This commit is contained in:
Livio Amstutz
2022-06-03 14:44:04 +02:00
committed by GitHub
parent da1f74fde0
commit 3a1569bd94
6 changed files with 51 additions and 24 deletions

View File

@@ -26,6 +26,7 @@ type API struct {
health health
router *mux.Router
externalSecure bool
http1HostName string
}
type health interface {
@@ -33,21 +34,14 @@ type health interface {
Instance(ctx context.Context) (*query.Instance, error)
}
func New(
port uint16,
router *mux.Router,
queries *query.Queries,
verifier *internal_authz.TokenVerifier,
authZ internal_authz.Config,
externalSecure bool,
http2HostName string,
) *API {
func New(port uint16, router *mux.Router, queries *query.Queries, verifier *internal_authz.TokenVerifier, authZ internal_authz.Config, externalSecure bool, http2HostName, http1HostName string) *API {
api := &API{
port: port,
verifier: verifier,
health: queries,
router: router,
externalSecure: externalSecure,
http1HostName: http1HostName,
}
api.grpcServer = server.CreateServer(api.verifier, authZ, queries, http2HostName)
api.routeGRPC()
@@ -59,7 +53,7 @@ func New(
func (a *API) RegisterServer(ctx context.Context, grpcServer server.Server) error {
grpcServer.RegisterServer(a.grpcServer)
handler, prefix, err := server.CreateGateway(ctx, grpcServer, a.port)
handler, prefix, err := server.CreateGateway(ctx, grpcServer, a.port, a.http1HostName)
if err != nil {
return err
}