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

Method Custom

bind.go:225–237  ·  view source on GitHub ↗

Custom To use custom binders, you have to use this method. You can register them from RegisterCustomBinder method of Fiber instance. They're checked by name, if it's not found, it will return an error. NOTE: WithAutoHandling/WithAutoHandling is still valid for Custom binders.

(name string, dest any)

Source from the content-addressed store, hash-verified

223// They're checked by name, if it's not found, it will return an error.
224// NOTE: WithAutoHandling/WithAutoHandling is still valid for Custom binders.
225func (b *Bind) Custom(name string, dest any) error {
226 binders := b.ctx.App().customBinders
227 for _, customBinder := range binders {
228 if customBinder.Name() == name {
229 if err := b.returnBindErr(customBinder.Parse(b.ctx, dest), name); err != nil {
230 return err
231 }
232 return b.validateStruct(dest)
233 }
234 }
235
236 return ErrCustomBinderNotFound
237}
238
239// Header binds the request header strings into the struct, map[string]string and map[string][]string.
240// Returns *BindError on parse failure (manual mode) or *Error with status 400 (auto-handling mode).

Callers 3

Test_Bind_CustomBinderFunction · 0.45

Calls 5

returnBindErrMethod · 0.95
validateStructMethod · 0.95
AppMethod · 0.65
NameMethod · 0.65
ParseMethod · 0.65

Tested by 3

Test_Bind_CustomBinderFunction · 0.36