feat: added contextKeys and domain in schema error

This commit is contained in:
mayur.popli
2025-04-10 15:30:02 +05:30
parent d329a31d45
commit bd3a836bdb
2 changed files with 5 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package main
import ( import (
"context" "context"
"net/http" "net/http"
"strings"
"github.com/beckn/beckn-onix/pkg/plugin/implementation/reqpreprocessor" "github.com/beckn/beckn-onix/pkg/plugin/implementation/reqpreprocessor"
) )
@@ -14,6 +15,9 @@ func (p provider) New(ctx context.Context, c map[string]string) (func(http.Handl
if role, ok := c["role"]; ok { if role, ok := c["role"]; ok {
config.Role = role config.Role = role
} }
if contextKeys, ok := c["contextKeys"]; ok {
config.ContextKeys = strings.Split(contextKeys, ",")
}
return reqpreprocessor.NewPreProcessor(config) return reqpreprocessor.NewPreProcessor(config)
} }

View File

@@ -78,7 +78,7 @@ func (v *schemaValidator) Validate(ctx context.Context, url *url.URL, data []byt
// Retrieve the schema from the cache. // Retrieve the schema from the cache.
schema, exists := v.schemaCache[schemaFileName] schema, exists := v.schemaCache[schemaFileName]
if !exists { if !exists {
return model.NewBadReqErr(errors.New("schema not found for domain")) return model.NewBadReqErr(errors.New(fmt.Sprintf("schema not found for domain: %s", domain)))
} }
var jsonData any var jsonData any