Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
type Model struct {
value []byte
func (m *Model) UnmarshalJSON(v []byte) error {
m.value = v
return nil
func Map(body io.Reader, v json.Unmarshaler) {
data, _ := ioutil.ReadAll(body)
type Controller struct {
mapper func(*http.Request, json.Unmarshaler) error
newModelFunc func() Model
func (c *Controller) Bla(r *http.Request) {
model := c.newModelFunc()
_ = c.mapper(r, &model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment