Parse data into the struct with gofiber/schema
(aliasTag string, out any, data map[string][]string, files ...map[string][]*multipart.FileHeader)
| 109 | |
| 110 | // Parse data into the struct with gofiber/schema |
| 111 | func parseToStruct(aliasTag string, out any, data map[string][]string, files ...map[string][]*multipart.FileHeader) error { |
| 112 | // Get decoder from pool |
| 113 | pool := getDecoderPool(aliasTag) |
| 114 | schemaDecoder := pool.Get().(*schema.Decoder) //nolint:errcheck,forcetypeassert // not needed |
| 115 | defer pool.Put(schemaDecoder) |
| 116 | |
| 117 | // Alias tag is baked in at build time (see decoderBuilder); setting it here |
| 118 | // would reset the decoder's type cache on every request. |
| 119 | if err := schemaDecoder.Decode(out, data, files...); err != nil { |
| 120 | return fmt.Errorf("%w", err) |
| 121 | } |
| 122 | |
| 123 | return nil |
| 124 | } |
| 125 | |
| 126 | // Parse data into the map |
| 127 | // thanks to https://github.com/gin-gonic/gin/blob/master/binding/binding.go |