Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add definition for overridable json engine#1121

Merged
Fenny merged 2 commits intogofiber:masterfrom
yquansah:yq-override-json
Jan 31, 2021
Merged

feat: add definition for overridable json engine#1121
Fenny merged 2 commits intogofiber:masterfrom
yquansah:yq-override-json

Conversation

@yquansah
Copy link
Contributor

Please provide enough information so that others can review your pull request:
The intention of this PR is to address the issue raised here: #1108

It allows for configuration of the underlying JSON marshaller/unmarshaller by clients of fiber. It will just default to the encoding/json implementation if one isn't provided a client.

Explain the details for making this change. What existing problem does the pull request solve?

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/

@welcome
Copy link

welcome bot commented Jan 20, 2021

Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@yquansah
Copy link
Contributor Author

Would appreciate suggestions on naming throughout this PR. Any and all feedback is more than welcomed.

@Fenny
Copy link
Member

Fenny commented Jan 22, 2021

Thanks for the PR, JSONEncoder would be better. What ya think @kiyonlin @ReneWerner87 @hi019 @yquansah

Copy link
Member

@renanbastos93 renanbastos93 left a comment

Choose a reason for hiding this comment

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

LGTM

@yquansah
Copy link
Contributor Author

yquansah commented Jan 23, 2021

@Fenny I agree. I can make that change 👍

After a bit of pondering on this, what do y'all think about having the definition of the interface as JSONEngine? Right now we only have a use case of encoding JSON, but I think this terminology I referred to above provides the most flexbile way for us to accommodate for any future iterations that we will provide in regards to JSON.

Thoughts?

I pushed my commit to lay out what I described above.

@yquansah yquansah force-pushed the yq-override-json branch 3 times, most recently from 4c99bb2 to 6fa63b2 Compare January 23, 2021 09:41
@yquansah yquansah changed the title feat: add custom definition for a json executor feat: add definition for overridable json engine Jan 24, 2021
@Fenny
Copy link
Member

Fenny commented Jan 25, 2021

@yquansah, I do agree that your solution is more fitting for a more flexible approach if we add a json decoder in the future. But I highly doubt we will add that because we think that is not the responsibility of a web framework.

I still suggest simplifying it by using the STD json marshal signatures ( we can always add Unmarshal in the future )

JSONMarshal func(interface{}) ([]byte, error)
// JSONUnmarshal func([]byte, interface{}) error

@yquansah
Copy link
Contributor Author

@Fenny Yeah I was thinking about that too, I do not think there will be a use case of doing json decoding, and if there is then it shouldn't be too hard to add. Let me know if my changes address what you are talking about.

@yquansah
Copy link
Contributor Author

@ReneWerner87 @Fenny Hey y'all just wanted to check in and see if there is anything left to do on this PR?

Copy link
Member

@ReneWerner87 ReneWerner87 left a comment

Choose a reason for hiding this comment

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

@yquansah
code looks good

can you add some words in
https://github.com/gofiber/docs/blob/master/api/fiber.md
-> PR in the docs repository

@Fenny
Copy link
Member

Fenny commented Jan 31, 2021

LGTM! Thanks!

@Fenny Fenny merged commit 267fd5e into gofiber:master Jan 31, 2021
@welcome
Copy link

welcome bot commented Jan 31, 2021

Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants