Skip to content
Myr

form.go

This file

Path

binding/form.go

64 lines · 1.3 KiB · Go

Last changed by

ci(golangci-lint): update configuration and fix lint issues (#4247)Flc゛before adoptionc4287b1

History of this file

Take it

The walk stopped after 200 commits: lines older than cf32d2d point at it.

chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d

lines 1–13why, one step back
1// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2// Use of this source code is governed by a MIT style3// license that can be found in the LICENSE file.45package binding67import (8 "errors"9 "net/http"10)1112const defaultMemory = 32 << 2013

ci(golangci-lint): update configuration and fix lint issues (#4247)Flc゛before adoptionc4287b1

lines 14–18why, one step back
14type (
15 formBinding struct{}16 formPostBinding struct{}17 formMultipartBinding struct{}18)

chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d

lines 19–64why, one step back
19
20func (formBinding) Name() string {21 return "form"22}2324func (formBinding) Bind(req *http.Request, obj any) error {25 if err := req.ParseForm(); err != nil {26 return err27 }28 if err := req.ParseMultipartForm(defaultMemory); err != nil && !errors.Is(err, http.ErrNotMultipart) {29 return err30 }31 if err := mapForm(obj, req.Form); err != nil {32 return err33 }34 return validate(obj)35}3637func (formPostBinding) Name() string {38 return "form-urlencoded"39}4041func (formPostBinding) Bind(req *http.Request, obj any) error {42 if err := req.ParseForm(); err != nil {43 return err44 }45 if err := mapForm(obj, req.PostForm); err != nil {46 return err47 }48 return validate(obj)49}5051func (formMultipartBinding) Name() string {52 return "multipart/form-data"53}5455func (formMultipartBinding) Bind(req *http.Request, obj any) error {56 if err := req.ParseMultipartForm(defaultMemory); err != nil {57 return err58 }59 if err := mappingByPtr(obj, (*multipartRequest)(req), "form"); err != nil {60 return err61 }6263 return validate(obj)64}