Skip to content

Commit

Permalink
Fix HTTP Server errors (#498)
Browse files Browse the repository at this point in the history
* Use unmarshalled struct for reading plugin config
* Use background context to prevent cancellation
  • Loading branch information
mostafa authored Mar 15, 2024
1 parent 2060af4 commit e88df0a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 1 addition & 5 deletions api/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit e88df0a

Please sign in to comment.