MCPcopy
hub / github.com/gofiber/fiber / parseToStruct

Function parseToStruct

binder/mapping.go:111–124  ·  view source on GitHub ↗

Parse data into the struct with gofiber/schema

(aliasTag string, out any, data map[string][]string, files ...map[string][]*multipart.FileHeader)

Source from the content-addressed store, hash-verified

109
110// Parse data into the struct with gofiber/schema
111func 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

Callers 4

parseFunction · 0.85

Calls 4

getDecoderPoolFunction · 0.85
GetMethod · 0.65
PutMethod · 0.65
ErrorfMethod · 0.65