-
Notifications
You must be signed in to change notification settings - Fork 182
Open
Description
TL;DR: Add support for camelCase and snake_case (commonly used formats for URL encoding) options in query.Values()
function.
This package, by default, uses the struct's field names for URL query parameters. While the package supports defining custom field names using the url
field tag, it is not possible add custom tags in certain scenarios, for example:
- When using external packages' struct definitions.
- When using structs that are tool-generated (protobuf, for example).
query/encode.go
package query
...
type Case int32
const (
CASE_DEFAULT Case = 0
CASE_CAMEL Case = 1
CASE_SNAKE Case = 2
CASE_PASCAL Case = 3
)
type Options struct {
EncodingCase Case
}
func Values(v interface{}, opts Options) (url.Values, error) {
...
}
usage.go
import "github.com/google/go-querystring/query"
import "some/external/package"
...
v, _ := query.Values(package.SomeStruct{}, Options{EncodingCase: query.CASE_CAMEL})
nxm
Metadata
Metadata
Assignees
Labels
No labels