From e88df0ae20424141e0ce84ead314e640495ef28e Mon Sep 17 00:00:00 2001 From: Mostafa Moradian Date: Fri, 15 Mar 2024 01:00:46 +0100 Subject: [PATCH] Fix HTTP Server errors (#498) * Use unmarshalled struct for reading plugin config * Use background context to prevent cancellation --- api/api.go | 2 +- api/http_server.go | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/api/api.go b/api/api.go index 6341bbcf..661fe031 100644 --- a/api/api.go +++ b/api/api.go @@ -100,7 +100,7 @@ func (a *API) GetGlobalConfig(_ context.Context, group *v1.Group) (*structpb.Str // GetPluginConfig returns the plugin configuration of the GatewayD. func (a *API) GetPluginConfig(context.Context, *emptypb.Empty) (*structpb.Struct, error) { - jsonData, err := json.Marshal(a.Config.PluginKoanf.All()) + jsonData, err := json.Marshal(a.Config.Plugin) if err != nil { metrics.APIRequestsErrors.WithLabelValues( "GET", "/v1/GatewayDPluginService/GetPluginConfig", codes.Internal.String(), diff --git a/api/http_server.go b/api/http_server.go index 4e533ddb..6f05b911 100644 --- a/api/http_server.go +++ b/api/http_server.go @@ -50,16 +50,12 @@ func (s *HTTPServer) Shutdown(ctx context.Context) { // CreateHTTPAPI creates a new HTTP API. func createHTTPAPI(options *Options) *http.Server { - ctx := context.Background() - ctx, cancel := context.WithCancel(ctx) - defer cancel() - // Register gRPC server endpoint // TODO: Make this configurable with TLS and Auth. rmux := runtime.NewServeMux() opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())} err := v1.RegisterGatewayDAdminAPIServiceHandlerFromEndpoint( - ctx, rmux, options.GRPCAddress, opts) + context.Background(), rmux, options.GRPCAddress, opts) if err != nil { options.Logger.Err(err).Msg("failed to start HTTP API") }