ggicci / httpin

🍡 HTTP Input for Go - HTTP Request from/to Go Struct (Bi-directional Data Binding between Go Struct and http.Request)
https://ggicci.github.io/httpin/
MIT License
315 stars 23 forks source link

Feature Request: ignore query parameters during encoding #110

Closed shawalli closed 3 weeks ago

shawalli commented 4 months ago

I'd like to have the option to ignore a query parameter during encoding if the parameter is empty. For simplicity, empty could be considered the zero value of the type.

If more complex support is desired, this could work with both pointers and values. If it is a pointer-type and nil, it can be considered empty and ignored (if the optional struct-tag option is given). If it is a value and is set to the type's zero-value, it can be considered empty and ignored (if the optional struct-tag option is given). WDYT?

ggicci commented 4 months ago

I guess the omitempty directive can help: https://github.com/ggicci/httpin/releases/tag/v0.19.0