2 ms·
I'm designing a Go backend to interact with a backbone client. Our API receives form data and spits out JSON, so the situation is not exactly the same. But we s
by polymathist 12y ago
I'm designing a Go backend to interact with a backbone client. Our API receives form data and spits out JSON, so the situation is not exactly the same. But we still ran into a similar problem with the way revel does parameter binding (if fields were not included in the form data, they ended up being interpreted as the zero value).
Check out this solution we came up with in a testing/learning project: https://github.com/cranberryofdoom/peeps/blob/master/app/controllers/persons.go#L38 https://github.com/cranberryofdoom/peeps/blob/master/app/con.... Basically we just had to do an extra check to see if the fields actually existed in the form data. Will probably generalize it later on to make it less verbose.