gadgeto icon indicating copy to clipboard operation
gadgeto copied to clipboard

tonic: Refactor handling of comma-separated lists

Open loopfz opened this issue 6 years ago • 2 comments

loopfz avatar Sep 06 '19 14:09 loopfz

I think we have to review the following, because it uses the current ExplodeTag. https://github.com/loopfz/gadgeto/blob/66ad4638c25c77275b47b89dd23d013c36aaae48/tonic/handler.go#L211 The code seems also useless. I don't think we need to take the ExplodeTag into account for default values. We could simply state that multiple values can be defined in a default tag, by delimiting them with a comma, and split that to feed the fieldValues slice. Later on, if the actual type of the field is not array or slice, we'll catch it and return an error. https://github.com/loopfz/gadgeto/blob/66ad4638c25c77275b47b89dd23d013c36aaae48/tonic/handler.go#L236 That will allow a user to specify multiple default values for arrays and slices, but we can't do much without adding complexity to prevent a misuse.

wI2L avatar Sep 06 '19 16:09 wI2L

Not closing this right now, but will need to reassess

loopfz avatar Mar 05 '21 15:03 loopfz