binding.go
func MultipartForm(formStruct interface{}, ifacePtr ...interface{}) martini.Handler {
	return func(context martini.Context, req *http.Request) {
		var errors Errors

		ensureNotPointer(formStruct)
		formStruct := reflect.New(reflect.TypeOf(formStruct))

		// This if check is necessary due to https://github.com/martini-contrib/csrf/issues/6
		if req.MultipartForm == nil {
			// Workaround for multipart forms returning nil instead of an error
			// when content is not multipart; see https://code.google.com/p/go/issues/detail?id=6334
			if multipartReader, err := req.MultipartReader(); err != nil {
				// TODO: Cover this and the next error check with tests
				errors.Add([]string{}, DeserializationError, err.Error())
			} else {
				form, parseErr := multipartReader.ReadForm(MaxMemory)
				if parseErr != nil {
					errors.Add([]string{}, DeserializationError, parseErr.Error())
				}
				req.MultipartForm = form
			}
		}

		mapForm(formStruct, req.MultipartForm.Value, req.MultipartForm.File, errors)
		validateAndMap(formStruct, context, errors, ifacePtr...)
	}

}
func MultipartForm(formStruct interface{}, ifacePtr ...interface{}) martini.Handler {
	return func(context martini.Context, req *http.Request) {
		var errors Errors

		ensureNotPointer(formStruct)
		formStruct := reflect.New(reflect.TypeOf(formStruct))

		// This if check is necessary due to https://github.com/martini-contrib/csrf/issues/6
		if req.MultipartForm == nil {
			// Workaround for multipart forms returning nil instead of an error
			// when content is not multipart; see https://code.google.com/p/go/issues/detail?id=6334
			if multipartReader, err := req.MultipartReader(); err != nil {
				// TODO: Cover this and the next error check with tests
				errors.Add([]string{}, DeserializationError, err.Error())
			} else {
				form, parseErr := multipartReader.ReadForm(MaxMemory)
				if parseErr != nil {
					errors.Add([]string{}, DeserializationError, parseErr.Error())
				}
				req.MultipartForm = form
			}
		}

		mapForm(formStruct, req.MultipartForm.Value, req.MultipartForm.File, errors)
		validateAndMap(formStruct, context, errors, ifacePtr...)
	}

}
func MultipartForm ( formStruct interface { } , ifacePtr ... interface { } ) martini . Handler { return func ( context martini . Context , req * http . Request ) { var errors Errors ensureNotPointer ( formStruct ) formStruct := reflect . New ( reflect . TypeOf ( formStruct ) ) // This if check is necessary due to https://github.com/martini-contrib/csrf/issues/6 if req . MultipartForm == nil { // Workaround for multipart forms returning nil instead of an error // when content is not multipart; see https://code.google.com/p/go/issues/detail?id=6334 if multipartReader , err := req . MultipartReader ( ) ; err != nil { // TODO: Cover this and the next error check with tests errors . Add ( [ ] string { } , DeserializationError , err . Error ( ) ) } else { form , parseErr := multipartReader . ReadForm ( MaxMemory ) if parseErr != nil { errors . Add ( [ ] string { } , DeserializationError , parseErr . Error ( ) ) } req . MultipartForm = form } } mapForm ( formStruct , req . MultipartForm . Value , req . MultipartForm . File , errors ) validateAndMap ( formStruct , context , errors , ifacePtr ... ) } }
// MultipartForm works much like Form, except it can parse multipart forms
// and handle file uploads. Like the other deserialization middleware handlers,
// you can pass in an interface to make the interface available for injection
// into other handlers later.
MultipartForm works much like Form except it can parse multipart forms and handle file uploads . Like the other deserialization middleware handlers you can pass in an interface to make the interface available for injection into other handlers later .