diff --git a/cmd/adapter/main.go b/cmd/adapter/main.go index d65e616..063377e 100644 --- a/cmd/adapter/main.go +++ b/cmd/adapter/main.go @@ -109,7 +109,9 @@ func run(ctx context.Context, configPath string) error { return fmt.Errorf("failed to initialize config: %w", err) } log.Infof(ctx, "Initializing logger with config: %+v", cfg.Log) - log.InitLogger(cfg.Log) + if err := log.InitLogger(cfg.Log); err != nil { + return fmt.Errorf("failed to initialize logger: %w", err) + } // Initialize plugin manager. log.Infof(ctx, "Initializing plugin manager") diff --git a/core/module/handler/config.go b/core/module/handler/config.go index 6803add..08d90a3 100644 --- a/core/module/handler/config.go +++ b/core/module/handler/config.go @@ -5,6 +5,7 @@ import ( "fmt" "net/http" + "github.com/beckn/beckn-onix/pkg/log" "github.com/beckn/beckn-onix/pkg/model" "github.com/beckn/beckn-onix/pkg/plugin" "github.com/beckn/beckn-onix/pkg/plugin/definition" @@ -112,6 +113,8 @@ func (s *Step) UnmarshalYAML(unmarshal func(interface{}) error) error { func DummyHandler(ctx context.Context, mgr PluginManager, cfg *Config) (http.Handler, error) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) - w.Write([]byte("Dummy Handler Response")) + if _, err := w.Write([]byte("Dummy Handler Response")); err != nil { + log.Error(context.Background(), err, "failed to write nack response") + } }), nil } diff --git a/core/module/handler/step.go b/core/module/handler/step.go index 448a937..bcd185d 100644 --- a/core/module/handler/step.go +++ b/core/module/handler/step.go @@ -164,18 +164,3 @@ func (b *broadcastStep) Run(ctx *model.StepContext) error { // TODO: Implement broadcast logic if needed return nil } - -// subscribeStep is a stub for subscription handling. -type subscribeStep struct{} - -// Run is a placeholder for future implementation. -func (s *subscribeStep) Run(ctx *model.StepContext) error { - // TODO: Implement subscription logic if needed - return nil -} - -// tracingStep wraps a Step with OpenTelemetry tracing -type tracingStep struct { - step definition.Step - name string -} diff --git a/pkg/response/response.go b/pkg/response/response.go index 9cb7e2c..d5326ac 100644 --- a/pkg/response/response.go +++ b/pkg/response/response.go @@ -8,6 +8,7 @@ import ( "net/http" "strconv" + "github.com/beckn/beckn-onix/pkg/log" "github.com/beckn/beckn-onix/pkg/model" ) @@ -48,7 +49,10 @@ func SendAck(w http.ResponseWriter) { // Set headers and write response w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - w.Write(data) + if _, err := w.Write(data); err != nil { + log.Error(context.Background(), err, "failed to write ack response") + } + } // nack sends a negative acknowledgment (NACK) response with an error message. @@ -73,7 +77,10 @@ func nack(w http.ResponseWriter, err *model.Error, status int) { // Set headers and write response w.Header().Set("Content-Type", "application/json") w.WriteHeader(status) // Assuming NACK means a bad request - w.Write(data) + if _, err := w.Write(data); err != nil { + log.Error(context.Background(), err, "failed to write nack response") + } + } func internalServerError(ctx context.Context) *model.Error {