Do not register API Middleware with validator gateway (#9055)

* Do not register API Middleware with validator gateway

* add nil checker

* revert bool

* nil check

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Radosław Kapka 2021-06-18 02:38:15 +02:00 committed by GitHub
parent 4d1b5f42af
commit fbed11b380
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 1 deletions

View File

@ -9,6 +9,10 @@ import (
type BeaconEndpointFactory struct {
}
func (f *BeaconEndpointFactory) IsNil() bool {
return f == nil
}
// Paths is a collection of all valid beacon chain API paths.
func (f *BeaconEndpointFactory) Paths() []string {
return []string{

View File

@ -23,6 +23,7 @@ type ApiProxyMiddleware struct {
type EndpointFactory interface {
Create(path string) (*Endpoint, error)
Paths() []string
IsNil() bool
}
// Endpoint is a representation of an API HTTP endpoint that should be proxied by the middleware.

View File

@ -231,7 +231,9 @@ func (g *Gateway) Start() {
}
}()
go g.registerApiMiddleware()
if g.apiMiddlewareAddr != "" && g.apiMiddlewareEndpointFactory != nil && !g.apiMiddlewareEndpointFactory.IsNil() {
go g.registerApiMiddleware()
}
}
// Status of grpc gateway. Returns an error if this service is unhealthy.

View File

@ -81,6 +81,7 @@ func TestValidatorGateway_StartStop(t *testing.T) {
validatorGateway.Start()
go func() {
require.LogsContain(t, hook, "Starting gRPC gateway")
require.LogsDoNotContain(t, hook, "Starting API middleware")
}()
err := validatorGateway.Stop()