add-marshal-unmarshal-text-param-for-common-date#164
Open
aaron-wego wants to merge 2 commits intomainfrom
Open
add-marshal-unmarshal-text-param-for-common-date#164aaron-wego wants to merge 2 commits intomainfrom
aaron-wego wants to merge 2 commits intomainfrom
Conversation
- 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
aaron-wego
commented
Nov 8, 2024
| if ctx != nil { | ||
| if basics, ok := ctx.Value(ctxBasics).(Basics); ok { | ||
| value, _ = basics[key] | ||
| value = basics[key] |
aaron-wego
commented
Nov 8, 2024
| if ctx != nil { | ||
| if extras, ok := ctx.Value(ctxExtras).(Extras); ok { | ||
| value, _ = extras[key] | ||
| value = extras[key] |
aaron-wego
commented
Nov 8, 2024
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 | ||
| } |
Contributor
Author
There was a problem hiding this comment.
not sure if these are useful in the future as it is not used by gin
gin-gonic/gin#3933
aaron-wego
commented
Nov 8, 2024
| } | ||
|
|
||
| // UnmarshalParam Parses the form's value to the Date | ||
| func (d *Date) UnmarshalParam(param string) (err error) { |
Contributor
Author
There was a problem hiding this comment.
Need to implement their BindUnmarshaler interface
gin-gonic/gin#3933
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


feat(binding): Support custom BindUnmarshaler for binding. gin-gonic/gin#3933
We need to upgrade our gin version from
1.9.1to1.10.0, but there are a lot of changes. We can defer this change for now.