Documentation
¶
Overview ¶
Package forms contains methods for handling form decoding and encoding.
Index ¶
- Variables
- func DecodeForm[T FormInput](req *http.Request) (T, bool, error)
- func DecodeMultiPartForm[T FormInput](req *http.Request) (T, bool, error)
- func DecodeMultipartFile(req *http.Request, field string) (*models.FileUpload, error)
- func DecodeMultipartValue(req *http.Request, field string) (string, error)
- type FileUpload
- type FormInput
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDecode indicates an error occurred during decoding. ErrDecode = errors.New("error in decoding") // ErrEncode indicates an error occurred during encoding. ErrEncode = errors.New("error in encoding") // ErrValidation indicates an error occurred during validation. ErrValidation = errors.New("validation failed") // ErrNoFormData indicates that no form data was parsed. ErrNoFormData = errors.New("no form data") // ErrSanitise indicates an error occurred during sanitisation. ErrSanitise = errors.New("sanitisation failed") )
Functions ¶
func DecodeForm ¶
DecodeForm will decode submitted form contents into the passed in type. It will perform validation of the type and will return the type and a boolean true if it is valid. If decoding the form submission fails, a non-nill error is returned.
func DecodeMultiPartForm ¶ added in v0.45.0
func DecodeMultipartFile ¶
DecodeMultipartFile will the file represented by the given field in a multipart form submission. It will perform validation of the file and will return the file object and a boolean true if it is valid. If decoding fails, a non-nill error is returned.
func DecodeMultipartValue ¶
DecodeMultipartValue will the file represented by the given field in a multipart form submission. It will perform validation of the file and will return the file object and a boolean true if it is valid. If decoding fails, a non-nill error is returned.
Types ¶
type FileUpload ¶
type FileUpload interface {
Set(hdr *multipart.FileHeader, data multipart.File)
}
FileUpload represents file data uploaded through a mutlipart form.