MCPcopy Create free account
hub / github.com/kataras/iris / ReadForm

Method ReadForm

context/context.go:2970–2985  ·  view source on GitHub ↗

ReadForm binds the request body of a form to the "formObject". It supports any kind of type, including custom structs. It will return nothing if request data are empty. The struct field tag is "form". Note that it will return nil error on empty form data if `Configuration.FireEmptyFormError` is fals

(formObject interface{})

Source from the content-addressed store, hash-verified

2968//
2969// Example: https://github.com/kataras/iris/blob/main/_examples/request-body/read-form/main.go
2970func (ctx *Context) ReadForm(formObject interface{}) error {
2971 values := ctx.FormValues()
2972 if len(values) == 0 {
2973 if ctx.app.ConfigurationReadOnly().GetFireEmptyFormError() {
2974 return ErrEmptyForm
2975 }
2976 return nil
2977 }
2978
2979 err := schema.DecodeForm(values, formObject)
2980 if err != nil && !IsErrPathCRSFToken(err) {
2981 return err
2982 }
2983
2984 return ctx.app.Validate(formObject)
2985}
2986
2987type (
2988 // MultipartRelated is the result of the context.ReadMultipartRelated method.

Callers 6

ReadBodyMethod · 0.95
PutByMethod · 0.80
mainFunction · 0.80
handleFormFunction · 0.80
createUserFunction · 0.80
SigninHandlerMethod · 0.80

Calls 4

FormValuesMethod · 0.95
GetFireEmptyFormErrorMethod · 0.65
ConfigurationReadOnlyMethod · 0.65
ValidateMethod · 0.65

Tested by

no test coverage detected