v0.5.0-rc5: added proxy.exclude label, refactored some code

This commit is contained in:
yusing
2024-09-17 17:56:41 +08:00
parent 83d1d027c6
commit be7a766cb2
8 changed files with 31 additions and 24 deletions

View File

@@ -2,7 +2,6 @@ package utils
import (
"github.com/santhosh-tekuri/jsonschema"
"github.com/yusing/go-proxy/common"
)
var schemaCompiler = func() *jsonschema.Compiler {
@@ -11,16 +10,13 @@ var schemaCompiler = func() *jsonschema.Compiler {
return c
}()
var schemaStorage = make(map[string] *jsonschema.Schema)
var schemaStorage = make(map[string]*jsonschema.Schema)
func GetSchema(path string) *jsonschema.Schema {
if common.NoSchemaValidation {
panic("bug: GetSchema called when schema validation disabled")
}
if schema, ok := schemaStorage[path]; ok {
return schema
}
schema := schemaCompiler.MustCompile(path)
schemaStorage[path] = schema
return schema
}
}