go-macaron / binding

Package binding is a middleware that provides request data binding and validation for Macaron.
Apache License 2.0
23 stars 17 forks source link

Cannot parse multipart form without form: attributes #10

Open emersion opened 8 years ago

emersion commented 8 years ago

This works:

type UploadForm struct {
    Title      string                `form:"Title"`
    TextUpload *multipart.FileHeader `form:"TextUpload"`
}

But this produces an empty struct:

type UploadForm struct {
    Title      string
    TextUpload *multipart.FileHeader
}
unknwon commented 8 years ago

But this produces an empty struct:

Why should this work?

emersion commented 8 years ago

Because it works with JSON:

type UploadForm struct {
    Title      string
    TextUpload *multipart.FileHeader
}

// is exactly the same as:

type UploadForm struct {
    Title      string `json:"Title"`
    TextUpload *multipart.FileHeader `json:"TextUpload"`
}
unknwon commented 8 years ago

Please dump your code and POST data here.