ozzo-routing icon indicating copy to clipboard operation
ozzo-routing copied to clipboard

Reading array query parameter as `[]time.Time`?

Open ganigeorgiev opened this issue 4 years ago • 0 comments

Reading array query parameters doesn't seem to work with common non primitive types (eg. []time.Time, []uuid.UUID, etc.).

Example:

// url: http://localhost:8090/api/test?Names=test1&Dates=2020-10-11T21%3A00%3A00.000Z

data := &struct{
    Names []string
    Dates []time.Time
}{}

ctx.Read(data) // result: { Names: [ "test1" ], Dates: [] }

I guess if an alias type with custom encoding.TextUnmarshaler is provided it would work, but that seems redundant because the non slice version is correctly unmarshalized.

ganigeorgiev avatar Oct 24 '20 18:10 ganigeorgiev