Update reqpreprocessor.go

This commit is contained in:
MohitKatare-protean
2025-04-09 08:21:32 +05:30
parent 0f9ca0cd62
commit e50dd96a34

View File

@@ -19,7 +19,7 @@ type Config struct {
ContextKeys []string ContextKeys []string
} }
const contextKeyField = "context" const contextKey = "context"
// NewPreProcessor returns a middleware that processes the incoming request, // NewPreProcessor returns a middleware that processes the incoming request,
// extracts the context field from the body, and adds relevant values (like subscriber ID). // extracts the context field from the body, and adds relevant values (like subscriber ID).
@@ -44,7 +44,7 @@ func NewPreProcessor(cfg *Config) (func(http.Handler) http.Handler, error) {
// Extract context from request. // Extract context from request.
reqContext, ok := req["context"].(map[string]interface{}) reqContext, ok := req["context"].(map[string]interface{})
if !ok { if !ok {
http.Error(w, fmt.Sprintf("%s field not found or invalid.", contextKeyField), http.StatusBadRequest) http.Error(w, fmt.Sprintf("%s field not found or invalid.", contextKey), http.StatusBadRequest)
return return
} }
var subID any var subID any