-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🔥 Add function to override form decoder setting #1100
🔥 Add function to override form decoder setting #1100
Conversation
🔥 Feature : SetBodyParserDecoder map all option to form decoder, use with BodyParserConfig, BodyParserType 🚨 Test : Test_Ctx_BodyParser_WithSetBodyParserDecoder
Any suggestion for moving forward on this PR will be appreciated, or any idea should be further investigate, wish to provide help, Thanks. |
👋 Hello. Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -244,6 +259,22 @@ var decoderPool = &sync.Pool{New: func() interface{} { | |||
return decoder | |||
}} | |||
|
|||
// SetBodyParserDecoder allow globally change the option of form decoder, update decoderPool | |||
func SetBodyParserDecoder(bodyParserConfig BodyParserConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use the method for the initial write of the decoder pool ?
https://github.com/gofiber/fiber/blob/master/ctx.go#L274
@rockcreation7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can help update the doc on this, thanks.
Please feel free to let me know anything that can help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or you mean I put a change to the initial write?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or you mean I put a change to the initial write?
@rockcreation7
yes exactly, with the initial set you can also use your method or ?
will merge it directly after the adjustment
@rockcreation7 can you rename it a bit, because the decoder is used by the query parser and body parser maybe something just called parser config or type |
Thanks, will update. |
Renamed function: Type: |
Please provide enough information so that others can review your pull request:
SetParserDecoder function map all option to form decoder, which allow you to change decoder option globally, use with type ParserConfig, ParserType.
Added Test_Ctx_BodyParser_WithSetParserDecoder for testing
Explain the details for making this change. What existing problem does the pull request solve?
You can do custom type in JSON format, Create custom type and related "UnmarshalJSON" method, But in form you need to register converter in decoder, I added option for supporting this feature. In order to solve problem when you need custom type for form.
Allow set the decoder's zeroEmpty to true, allow not skipping empty input as it will overwrite existing value. 🐛 BodyParser does not save empty string to field #1084
Commit formatting
Use emojis on commit messages so it provides an easy way of identifying the purpose or intention of a commit. Check out the emoji cheatsheet here: https://gitmoji.carloscuesta.me/