MCPcopy
hub / github.com/labstack/echo / FormFieldBinder

Function FormFieldBinder

binder.go:168–189  ·  view source on GitHub ↗

FormFieldBinder creates form field value binder For all requests, FormFieldBinder parses the raw query from the URL and uses query params as form fields For POST, PUT, and PATCH requests, it also reads the request body, parses it as a form and uses query params as form fields. Request body paramete

(c *Context)

Source from the content-addressed store, hash-verified

166// which parses form data from BOTH URL and BODY if content type is not MIMEMultipartForm
167// See https://golang.org/pkg/net/http/#Request.ParseForm
168func FormFieldBinder(c *Context) *ValueBinder {
169 vb := &ValueBinder{
170 failFast: true,
171 ValueFunc: func(sourceParam string) string {
172 return c.Request().FormValue(sourceParam)
173 },
174 ErrorFunc: NewBindingError,
175 }
176 vb.ValuesFunc = func(sourceParam string) []string {
177 if c.Request().Form == nil {
178 // this is same as `Request().FormValue()` does internally
179 _, _ = c.MultipartForm() // we want to trigger c.request.ParseMultipartForm(c.formParseMaxMemory)
180 }
181 values, ok := c.Request().Form[sourceParam]
182 if !ok {
183 return nil
184 }
185 return values
186 }
187
188 return vb
189}
190
191// FailFast set internal flag to indicate if binding methods will return early (without binding) when previous bind failed
192// NB: call this method before any other binding methods as it modifies binding methods behaviour

Callers 1

TestFormFieldBinderFunction · 0.85

Calls 3

FormValueMethod · 0.80
RequestMethod · 0.80
MultipartFormMethod · 0.80

Tested by 1

TestFormFieldBinderFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…