(aliasTag string, parserConfig ParserConfig)
| 62 | } |
| 63 | |
| 64 | func decoderBuilder(aliasTag string, parserConfig ParserConfig) any { |
| 65 | decoder := schema.NewDecoder() |
| 66 | decoder.IgnoreUnknownKeys(parserConfig.IgnoreUnknownKeys) |
| 67 | // Bake the per-source tag once (pools are keyed per tag); doing it per |
| 68 | // request reset the decoder's type cache. ParserConfig.SetAliasTag is not |
| 69 | // honored here: one global tag is incompatible with per-source binding. |
| 70 | decoder.SetAliasTag(aliasTag) |
| 71 | for _, v := range parserConfig.ParserType { |
| 72 | decoder.RegisterConverter(reflect.ValueOf(v.CustomType).Interface(), v.Converter) |
| 73 | } |
| 74 | decoder.ZeroEmpty(parserConfig.ZeroEmpty) |
| 75 | return decoder |
| 76 | } |
| 77 | |
| 78 | func init() { |
| 79 | decoderPoolMu.Lock() |
no outgoing calls