Home / File/ form.go — fiber Source File

form.go — fiber Source File

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

File go DataBinding PayloadParsers 1 imports 6 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  3017faab_d5b2_b3e1_f0fc_44a14bdb981a["form.go"]
  a13b8bb1_d603_cd28_c9dc_32f76c8f8637["multipart"]
  3017faab_d5b2_b3e1_f0fc_44a14bdb981a --> a13b8bb1_d603_cd28_c9dc_32f76c8f8637
  style 3017faab_d5b2_b3e1_f0fc_44a14bdb981a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package binder

import (
	"mime/multipart"
	"sync"

	"github.com/gofiber/utils/v2"
	"github.com/valyala/fasthttp"
)

const MIMEMultipartForm string = "multipart/form-data"

var (
	formMapPool = sync.Pool{
		New: func() any {
			return make(map[string][]string)
		},
	}
	formFileMapPool = sync.Pool{
		New: func() any {
			return make(map[string][]*multipart.FileHeader)
		},
	}
)

// FormBinding is the form binder for form request body.
type FormBinding struct {
	EnableSplitting bool
}

// Name returns the binding name.
func (*FormBinding) Name() string {
	return "form"
}

// Bind parses the request body and returns the result.
func (b *FormBinding) Bind(req *fasthttp.Request, out any) error {
	// Handle multipart form
	if FilterFlags(utils.UnsafeString(req.Header.ContentType())) == MIMEMultipartForm {
		return b.bindMultipart(req, out)
	}

	data := acquireFormMap()
	defer releaseFormMap(data)

	for key, val := range req.PostArgs().All() {
		k := utils.UnsafeString(key)
		v := utils.UnsafeString(val)
		if err := formatBindData(b.Name(), out, data, k, v, b.EnableSplitting, true); err != nil {
			return err
		}
	}

	return parse(b.Name(), out, data)
}

// bindMultipart parses the request body and returns the result.
func (b *FormBinding) bindMultipart(req *fasthttp.Request, out any) error {
	multipartForm, err := req.MultipartForm()
	if err != nil {
// ... (65 more lines)

Domain

Subdomains

Classes

Dependencies

  • multipart

Frequently Asked Questions

What does form.go do?
form.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 form.go?
form.go defines 6 function(s): acquireFileHeaderMap, acquireFormMap, clearFileHeaderMap, clearFormMap, releaseFileHeaderMap, releaseFormMap.
What does form.go depend on?
form.go imports 1 module(s): multipart.
Where is form.go in the architecture?
form.go is located at binder/form.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