Home / File/ mapping.go — fiber Source File

mapping.go — fiber Source File

Architecture documentation for mapping.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go DataBinding PayloadParsers 1 imports 19 functions 3 classes

Entity Profile

Dependency Diagram

graph LR
  5a1aea01_8a49_a350_626b_5da5e78187fd["mapping.go"]
  adf3d4e8_4d86_86c1_e6cc_281d7b4104af["fmt"]
  5a1aea01_8a49_a350_626b_5da5e78187fd --> adf3d4e8_4d86_86c1_e6cc_281d7b4104af
  style 5a1aea01_8a49_a350_626b_5da5e78187fd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package binder

import (
	"fmt"
	"maps"
	"mime/multipart"
	"reflect"
	"strings"
	"sync"

	"github.com/gofiber/utils/v2"
	"github.com/valyala/bytebufferpool"

	"github.com/gofiber/schema"
)

// ParserConfig form decoder config for SetParserDecoder
type ParserConfig struct {
	SetAliasTag       string
	ParserType        []ParserType
	IgnoreUnknownKeys bool
	ZeroEmpty         bool
}

// ParserType require two element, type and converter for register.
// Use ParserType with BodyParser for parsing custom type in form data.
type ParserType struct {
	CustomType any
	Converter  func(string) reflect.Value
}

var (
	decoderPoolMu sync.RWMutex
	// decoderPoolMap helps to improve binders
	decoderPoolMap = map[string]*sync.Pool{}
	// tags is used to classify parser's pool
	tags = []string{"header", "respHeader", "cookie", "query", "form", "uri"}
)

func getDecoderPool(tag string) *sync.Pool {
	decoderPoolMu.RLock()
	pool := decoderPoolMap[tag]
	if pool == nil {
		decoderPoolMu.RUnlock()
		panic(fmt.Sprintf("decoder pool not initialized for tag %q", tag))
	}
	decoderPoolMu.RUnlock()

	return pool
}

// SetParserDecoder allow globally change the option of form decoder, update decoderPool
func SetParserDecoder(parserConfig ParserConfig) {
	decoderPoolMu.Lock()
	defer decoderPoolMu.Unlock()

	for _, tag := range tags {
		decoderPoolMap[tag] = &sync.Pool{New: func() any {
			return decoderBuilder(parserConfig)
		}}
// ... (346 more lines)

Domain

Subdomains

Dependencies

  • fmt

Frequently Asked Questions

What does mapping.go do?
mapping.go is a source file in the fiber codebase, written in go. It belongs to the DataBinding domain, PayloadParsers subdomain.
What functions are defined in mapping.go?
mapping.go defines 19 function(s): FilterFlags, SetParserDecoder, assignBindData, buildFieldInfo, decoderBuilder, equalFieldType, fieldName, formatBindData, getDecoderPool, getFieldCache, and 9 more.
What does mapping.go depend on?
mapping.go imports 1 module(s): fmt.
Where is mapping.go in the architecture?
mapping.go is located at binder/mapping.go (domain: DataBinding, subdomain: PayloadParsers, directory: binder).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free