Any way to pre-initialize the struct?
matdurand opened this issue · 4 comments
Hi,
I would like to be able to create and initialize an empty struct for each call to Decode
instead of httpin creating a new instance using
rootValue := reflect.New(r.Type)
Any chance there is an option to do that?
Hi, could you explain what's the purpose of creating the instance by yourself, is it performance concern?
Not performance no. Basically we already have a way to initialize structs with default values in our business logic, so I don't want to introduce a new syntax with httpin default annotation to set default values at the http controller layer, since it will ultimately lead to someone making a mistaken in the default values definition, thinking they were in the business layer but in reality they are in the http layer.
So if I could create the struct myself and have httpin fill it from the request, I could apply our default values using the same way we do it in our business logic and then pass it to httpin.