Skip to content

Conversation

@aaron-wego
Copy link
Contributor

We need to upgrade our gin version from 1.9.1 to 1.10.0, but there are a lot of changes. We can defer this change for now.

- add marshal and unmarshal text to be able to use in query params
- minor refactor in context.go
- added tests
- added UnmarshalParam to support query param
gin-gonic/gin#3933
if ctx != nil {
if basics, ok := ctx.Value(ctxBasics).(Basics); ok {
value, _ = basics[key]
value = basics[key]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

if ctx != nil {
if extras, ok := ctx.Value(ctxExtras).(Extras); ok {
value, _ = extras[key]
value = extras[key]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Comment on lines +28 to +38
func (d *Date) UnmarshalText(text []byte) (err error) {
s := strings.Trim(string(text), `"`)
parsedTime, err := time.Parse(layout, s)
*d = Date(parsedTime)
return
}

// MarshalText marshall Date into Text
func (d Date) MarshalText() ([]byte, error) {
return []byte(d.quote()), nil
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if these are useful in the future as it is not used by gin
gin-gonic/gin#3933

}

// UnmarshalParam Parses the form's value to the Date
func (d *Date) UnmarshalParam(param string) (err error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to implement their BindUnmarshaler interface
gin-gonic/gin#3933

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant