🔥 feat: Add support for Msgpack#3565
Conversation
WalkthroughThis change introduces MessagePack (MsgPack) encoding and decoding support throughout the Fiber web framework. It adds MsgPack binder logic, context methods for MsgPack serialization, configuration options for custom MsgPack encoders/decoders, new MIME type constants, and comprehensive tests and documentation for MsgPack handling in both request and response flows. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant FiberApp
participant Bind
participant MsgPackBinding
Client->>FiberApp: HTTP request (Content-Type: application/vnd.msgpack)
FiberApp->>Bind: Bind.Body(out)
Bind->>MsgPackBinding: Bind(body, out)
MsgPackBinding->>Bind: Decode MsgPack body into struct
Bind->>FiberApp: Return bound struct
FiberApp->>Client: HTTP response
sequenceDiagram
participant Client
participant FiberApp
participant Ctx
Client->>FiberApp: HTTP request (Accept: application/vnd.msgpack)
FiberApp->>Ctx: AutoFormat(data)
Ctx->>Ctx: MsgPack(data)
Ctx->>Client: HTTP response (Content-Type: application/vnd.msgpack, MsgPack-encoded body)
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Summary of Changes
Hello @hotrungnhan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the Fiber web framework by introducing native support for MessagePack (MsgPack), a highly efficient binary serialization format. This addition allows applications to leverage MsgPack for both request binding and response generation, providing a standardized and performant alternative to existing JSON, XML, and CBOR functionalities, ultimately leading to smaller payload sizes and faster data processing.
Highlights
- Core MsgPack Integration: Adds native support for MessagePack (MsgPack) serialization and deserialization within the Fiber framework, enabling efficient binary data handling.
- New Context Method: Introduces
c.MsgPack()for easily sending MsgPack encoded responses, similar to existingc.JSON()andc.XML()methods. - New Binder Functionality: Adds
c.Bind().MsgPack()to parse incoming MsgPack request bodies, providing a standardized way to handle MsgPack input. - Content Negotiation Enhancement: Integrates MsgPack into
c.Format()andc.AutoFormat()methods, allowing for automatic content type selection based on the client'sAcceptheaders. - Configurable Encoders/Decoders: Allows custom MsgPack encoder and decoder implementations to be configured via
Appsettings, providing flexibility for advanced use cases. - Performance Benchmarks & Documentation: Includes new benchmarks to measure MsgPack performance and updates API documentation (
/docs/api/bind.md,/docs/api/ctx.md) with clear usage examples. - New Dependency: Adds
github.com/shamaton/msgpack/v2as the underlying library for MsgPack serialization and deserialization.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Pull Request Overview
Adds native MessagePack (MsgPack) support to Fiber for efficient binary serialization, including new binder and context methods, documentation, and benchmarks.
- Introduces
c.MsgPack()and binder support mirroring existing JSON/XML/CBOR APIs - Updates documentation and examples in
/docs/api/*for MsgPack usage - Adds tests and benchmarks for MsgPack encoding/decoding and content negotiation
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Added github.com/shamaton/msgpack/v2 and bumped utils/v2 |
| app.go | Initialized default MsgPack encoder/decoder in New |
| constants.go | Added MIMEApplicationMsgPack constant |
| ctx.go | Added MsgPack method and AutoFormat support for MsgPack |
| ctx_interface_gen.go | Extended Ctx interface with MsgPack(...) |
| bind.go | Added Bind.MsgPack and MsgPack branch in Body dispatcher |
| binder/msgpack.go | Implemented MsgPackBinding |
| binder/mapping.go | Registered "msgpack" tag for binder pools |
| binder/binder.go | Created MsgPackBinderPool |
| binder/msgpack_test.go | Added unit tests and benchmarks for MsgPack binder |
| binder/binder_test.go | Included MsgPackBinding in binder pool tests |
| docs/api/ctx.md | Documented MsgPack context methods and AutoFormat examples |
| docs/api/bind.md | Documented MsgPack binding and examples |
| ctx_test.go | Added tests and benchmarks for c.MsgPack and AutoFormat |
| bind_test.go | Added tests and benchmarks for Bind.MsgPack |
Comments suppressed due to low confidence (5)
docs/api/bind.md:23
- Remove the space between
]and(in the Markdown link so it reads[MsgPack](#msgpack)to ensure the anchor works correctly.
- [MsgPack] (#msgpack)
docs/api/bind.md:53
- The
msgpacktag for thePassfield is incorrectly set to"name"; it should bemsgpack:"pass"to match the field name.
Pass string `json:"pass" xml:"pass" form:"pass" msgpack:"name"`
docs/api/ctx.md:1834
- The example comment shows
application/jsonbutc.MsgPackshould setapplication/vnd.msgpackby default.
// => Content-Type: application/json
bind.go:244
- [nitpick] Consider updating the comment to clarify that
MsgPackbinds the request body bytes as MsgPack, not a string: e.g.// MsgPack binds a MsgPack-encoded request body into the struct.
// MsgPack binds the body string into the struct.
go.mod:7
- The
utils/v2version contains an extra.0in the pre-release identifier; please verify the intended module version string.
github.com/gofiber/utils/v2 v2.0.0-beta.9.0.20250704191817-dad0ed942ea6
There was a problem hiding this comment.
Code Review
This pull request introduces native MessagePack support to Fiber, which is a great addition for performance-critical applications. The implementation follows existing framework patterns well. My review focuses on improving the correctness of the new tests and fixing some minor issues in the documentation to ensure everything is clear and accurate.
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (2)
docs/api/bind.md (2)
23-23: Fix markdown link syntax.Remove the extra space before the parenthesis in the MsgPack link.
- - [MsgPack] (#msgpack) + - [MsgPack](#msgpack)
53-53: Fix inconsistent struct tag.The msgpack struct tag should be "pass" to match the field name and be consistent with other tags.
- Pass string `json:"pass" xml:"pass" form:"pass" msgpack:"name"` + Pass string `json:"pass" xml:"pass" form:"pass" msgpack:"pass"`
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
go.modis excluded by!**/*.modgo.sumis excluded by!**/*.sum,!**/*.sum
📒 Files selected for processing (14)
app.go(3 hunks)bind.go(2 hunks)bind_test.go(3 hunks)binder/binder.go(1 hunks)binder/binder_test.go(1 hunks)binder/mapping.go(1 hunks)binder/msgpack.go(1 hunks)binder/msgpack_test.go(1 hunks)constants.go(1 hunks)ctx.go(3 hunks)ctx_interface_gen.go(4 hunks)ctx_test.go(5 hunks)docs/api/bind.md(4 hunks)docs/api/ctx.md(4 hunks)
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Feature request #3224 has been created to add support for square bracket notation and comma-separated values in multipart form data in Fiber, while maintaining binary data transfer capabilities. This would bring parity with the existing form-urlencoded functionality.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Fiber currently supports square bracket notation in form data with 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. The implementation for form-urlencoded is in ctx.go (BodyParser method), while multipart form data handling needs enhancement to support this feature.
Learnt from: ReneWerner87
PR: gofiber/fiber#3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
binder/binder.go (4)
Learnt from: sixcolors
PR: gofiber/fiber#3051
File: middleware/session/session.go:215-216
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The `session.Save()` method in the `middleware/session` package returns the `Session` back to `sync.Pool`.
Learnt from: sixcolors
PR: gofiber/fiber#3051
File: middleware/session/session.go:215-216
Timestamp: 2024-06-30T00:38:06.580Z
Learning: The `session.Save()` method in the `middleware/session` package returns the `Session` back to `sync.Pool`.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/session.go:46-61
Timestamp: 2024-10-02T23:02:12.306Z
Learning: In this codebase, the `sessionPool` only contains `Session` instances, so type assertions without additional checks are acceptable.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/session.go:46-61
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In this codebase, the `sessionPool` only contains `Session` instances, so type assertions without additional checks are acceptable.
app.go (8)
Learnt from: ReneWerner87
PR: gofiber/fiber#3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
Learnt from: gaby
PR: gofiber/fiber#3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Fiber currently supports square bracket notation in form data with 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. The implementation for form-urlencoded is in ctx.go (BodyParser method), while multipart form data handling needs enhancement to support this feature.
Learnt from: gaby
PR: gofiber/fiber#3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.
Learnt from: sixcolors
PR: gofiber/fiber#2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The project uses the testify/assert package for assertions in unit tests.
Learnt from: sixcolors
PR: gofiber/fiber#2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The project uses the testify/assert package for assertions in unit tests.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-02T23:03:31.727Z
Learning: Unit tests in this project use testify require.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Unit tests in this project use testify require.
docs/api/bind.md (1)
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Fiber currently supports square bracket notation in form data with 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. The implementation for form-urlencoded is in ctx.go (BodyParser method), while multipart form data handling needs enhancement to support this feature.
bind_test.go (1)
Learnt from: ReneWerner87
PR: gofiber/fiber#3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
ctx_interface_gen.go (4)
Learnt from: gaby
PR: gofiber/fiber#3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.
Learnt from: gaby
PR: gofiber/fiber#3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-09-25T15:57:10.221Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.
ctx.go (2)
Learnt from: gaby
PR: gofiber/fiber#3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.
Learnt from: gaby
PR: gofiber/fiber#3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.
docs/api/ctx.md (6)
Learnt from: gaby
PR: gofiber/fiber#3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.
Learnt from: gaby
PR: gofiber/fiber#3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.
Learnt from: ReneWerner87
PR: gofiber/fiber#3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-09-25T15:57:10.221Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Fiber currently supports square bracket notation in form data with 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. The implementation for form-urlencoded is in ctx.go (BodyParser method), while multipart form data handling needs enhancement to support this feature.
ctx_test.go (14)
undefined
<retrieved_learning>
Learnt from: gaby
PR: #3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, Context() is being renamed to RequestCtx(), and UserContext() to Context() to improve clarity and align with Go's context conventions.
</retrieved_learning>
<retrieved_learning>
Learnt from: ReneWerner87
PR: #3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the Test method in app.go.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The project uses the testify/assert package for assertions in unit tests.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The project uses the testify/assert package for assertions in unit tests.
</retrieved_learning>
<retrieved_learning>
Learnt from: gaby
PR: #3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the middleware/adaptor/adaptor.go file of the Fiber framework, when updating context handling, replacing c.Context() with c.RequestCtx() is appropriate to access the fasthttp.RequestCtx.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the Fiber framework tests, using ctx.Response.Header.Cookie may not be suitable for parsing cookies from the response header, as it requires a *Cookie and fills it rather than returning a string value; thus, manual parsing of the Set-Cookie header may be necessary.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-09-25T15:57:10.221Z
Learning: In the Fiber framework tests, using ctx.Response.Header.Cookie may not be suitable for parsing cookies from the response header, as it requires a *Cookie and fills it rather than returning a string value; thus, manual parsing of the Set-Cookie header may be necessary.
</retrieved_learning>
<retrieved_learning>
Learnt from: efectn
PR: #3162
File: hooks_test.go:228-228
Timestamp: 2024-12-13T08:14:22.851Z
Learning: In Go test files, prefer using the require methods from the testify package for assertions instead of manual comparisons and calls to t.Fatal or t.Fatalf.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-02T23:03:31.727Z
Learning: Unit tests in this project use testify require.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Unit tests in this project use testify require.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3016
File: middleware/session/config.go:122-122
Timestamp: 2024-09-25T16:18:34.719Z
Learning: In DefaultErrorHandler(c *fiber.Ctx, err error), since c is a pointer to an interface, we need to dereference *c when calling interface methods like SendStatus.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3016
File: middleware/session/config.go:122-122
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In DefaultErrorHandler(c *fiber.Ctx, err error), since c is a pointer to an interface, we need to dereference *c when calling interface methods like SendStatus.
</retrieved_learning>
<retrieved_learning>
Learnt from: efectn
PR: #3162
File: app_test.go:893-895
Timestamp: 2024-11-29T12:37:27.581Z
Learning: In the Test_App_ShutdownWithContext function in app_test.go, the clientDone channel is used to synchronize the client's request completion before proceeding, eliminating the need for additional time.Sleep calls.
</retrieved_learning>
<retrieved_learning>
Learnt from: gaby
PR: #3170
File: ctx_test.go:1721-1724
Timestamp: 2024-10-16T12:12:30.506Z
Learning: In the Go unit tests in ctx_test.go, it is acceptable to use invalid CIDR notation such as "0.0.0.1/31junk" for testing purposes.
</retrieved_learning>
🧬 Code Graph Analysis (3)
binder/binder.go (1)
binder/msgpack.go (2)
MsgPackBinding(6-8)MsgPackBinding(11-13)
binder/binder_test.go (2)
binder/binder.go (2)
GetFromThePool(76-83)MsgPackBinderPool(68-74)binder/msgpack.go (2)
MsgPackBinding(6-8)MsgPackBinding(11-13)
ctx.go (1)
constants.go (1)
MIMEApplicationMsgPack(30-30)
🔇 Additional comments (30)
binder/mapping.go (2)
37-37: LGTM: Consistent addition of msgpack tag.The addition of "msgpack" to the tags array correctly extends parser pool classification for the new MsgPack binding support.
211-228: Resolved: MsgPackBinding Doesn’t Use the Field CacheAfter verifying the code, the MsgPack bindings simply invoke the external
msgpack.Unmarshal(orutils.MsgPackUnmarshal) and never call into ourmapping.getFieldCacheorbuildFieldInfologic. There is no risk of a panic or missing cache entry because the MsgPack binder bypasses our field‐caching entirely.constants.go (1)
30-30: LGTM: Correct MsgPack MIME type constant.The MIME type constant
"application/vnd.msgpack"is correct and follows the established naming convention for MIME type constants.binder/binder.go (1)
68-74: LGTM: Consistent MsgPack binder pool implementation.The sync.Pool follows the established pattern for other binder pools. The nil initialization for
MsgPackDecoderis appropriate, as it should be configured from the app's MsgPack decoder setting before use.binder/binder_test.go (1)
32-32: LGTM: Appropriate test coverage for MsgPack binder pool.The test correctly verifies that
MsgPackBindingcan be retrieved fromMsgPackBinderPool, maintaining consistency with other binder pool tests.app.go (3)
31-31: LGTM: Appropriate MsgPack library import.Using
github.com/shamaton/msgpack/v2is a well-established and maintained MessagePack library for Go.
324-336: LGTM: Consistent config field addition for MsgPack support.The
MsgPackEncoderandMsgPackDecoderfields follow the exact same pattern as existing JSON, CBOR, and XML encoder/decoder fields, ensuring API consistency.
606-611: LGTM: Proper default initialization for MsgPack codecs.The initialization logic correctly sets default MsgPack marshal/unmarshal functions when not explicitly configured, following the same pattern as other serialization formats.
bind.go (2)
244-260: LGTM! MsgPack method follows established patterns.The implementation correctly follows the same pattern as other binding methods (JSON, CBOR, XML) with proper resource management using sync.Pool, consistent error handling, and struct validation.
284-285: LGTM! Content-type dispatch correctly integrated.The MsgPack case is properly added to the Body method's content-type switch statement, maintaining consistency with existing dispatching logic.
binder/msgpack.go (1)
1-24: LGTM! Clean MsgPack binder implementation.The MsgPackBinding struct correctly implements the binding interface with proper method signatures and follows the established pattern used by other binders in the framework.
ctx.go (3)
561-561: LGTM! MsgPack correctly integrated into content negotiation.The addition of "msgpack" to the AutoFormat accepts list properly enables content negotiation for MessagePack responses.
581-582: LGTM! Proper dispatch to MsgPack serialization.The msgpack case correctly calls the new MsgPack method, maintaining consistency with the AutoFormat switch pattern.
915-931: LGTM! MsgPack method follows established serialization patterns.The implementation correctly mirrors the JSON and CBOR methods with proper encoder usage, content-type header setting, and error handling. The method signature and behavior are consistent with other serialization methods.
docs/api/bind.md (2)
197-231: LGTM! Comprehensive MsgPack documentation.The new MsgPack binding section provides clear explanations, proper code examples, and practical curl commands for testing. The documentation follows the established pattern used for other binding methods.
44-44: LGTM! Well-integrated MsgPack content type support.The MsgPack content type and struct tag are properly documented in the table, and the curl example demonstrates correct usage of the binary MessagePack format.
Also applies to: 76-77
bind_test.go (3)
882-883: LGTM! Struct tags follow established patterns.The addition of
msgpackstruct tags is consistent with existing serialization formats and uses appropriate field names.
942-944: LGTM! New MsgPack test case follows established patterns.The test correctly uses the MsgPack MIME type and appears to use valid MsgPack-encoded data for testing body binding.
1144-1167: LGTM! New MsgPack benchmark is well-implemented.The benchmark correctly uses MsgPack content type with MsgPack-encoded data and follows established benchmark patterns. The implementation is consistent and accurate.
docs/api/ctx.md (2)
1452-1452: LGTM! MsgPack added to supported content types.The addition of
application/vnd.msgpackto the AutoFormat supported content types is consistent with the new MsgPack functionality.
1482-1484: LGTM! Good example for MsgPack content negotiation.The example demonstrates proper usage of AutoFormat with MsgPack Accept headers.
ctx_interface_gen.go (3)
187-191: LGTM! MsgPack method properly integrated into interface.The method signature is consistent with other serialization methods (JSON, CBOR) and follows the established pattern with optional content-type parameter.
57-60: LGTM! Enhanced documentation for context methods.The expanded comments provide valuable clarification about the no-op behavior of these methods due to fasthttp limitations, with proper reference to the GitHub issue for context.
Also applies to: 67-68, 83-88
329-332: LGTM! Improved Subdomains method documentation.The enhanced documentation clearly explains the offset behavior and return conditions.
ctx_test.go (6)
1068-1081: LGTM! Benchmark test case for MsgPack content negotiation.The new benchmark test case properly tests the content negotiation behavior when "msgpack" is requested but not available in the offers. The expectation of no error suggests proper fallback handling.
1104-1108: LGTM! AutoFormat test follows established patterns.The MsgPack test case correctly follows the same pattern as other AutoFormat tests, converting the response body to string for comparison.
1159-1172: LGTM! Comprehensive struct serialization test for MsgPack.The test properly verifies that AutoFormat correctly serializes structured data to MessagePack binary format. The expected byte array appears to be a valid MessagePack representation of the test data.
1230-1245: LGTM! Dedicated MsgPack AutoFormat benchmark.The benchmark follows the established pattern of other AutoFormat benchmarks and provides proper performance measurement for MsgPack serialization.
3744-3823: LGTM! Comprehensive MsgPack method testing.This test provides excellent coverage of the MsgPack functionality:
- ✅ Complex number handling (different from JSON behavior)
- ✅ Basic and custom content type support
- ✅ Various data types with correct binary expectations
- ✅ Custom encoder configuration testing
- ✅ Follows established patterns from JSON/CBOR tests
The binary output expectations appear to be valid MessagePack encodings.
3802-3823: LGTM! Well-structured MsgPack performance benchmark.The benchmark follows the established pattern of other serialization method benchmarks and provides proper performance measurement with result verification.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
bind_test.go (1)
1131-1131: Fix content type inconsistency in JSON benchmark.The benchmark sets MsgPack content type but uses JSON-marshaled data, which will cause binding failures. The content type should match the data format.
Apply this fix to use the correct content type:
- c.Request().Header.SetContentType(MIMEApplicationMsgPack) + c.Request().Header.SetContentType(MIMEApplicationJSON)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
go.modis excluded by!**/*.modgo.sumis excluded by!**/*.sum,!**/*.sum
📒 Files selected for processing (14)
app.go(3 hunks)bind.go(2 hunks)bind_test.go(3 hunks)binder/binder.go(1 hunks)binder/binder_test.go(1 hunks)binder/mapping.go(1 hunks)binder/msgpack.go(1 hunks)binder/msgpack_test.go(1 hunks)constants.go(1 hunks)ctx.go(3 hunks)ctx_interface_gen.go(4 hunks)ctx_test.go(5 hunks)docs/api/bind.md(4 hunks)docs/api/ctx.md(4 hunks)
✅ Files skipped from review due to trivial changes (1)
- binder/mapping.go
🚧 Files skipped from review as they are similar to previous changes (11)
- constants.go
- binder/binder.go
- binder/binder_test.go
- ctx.go
- app.go
- bind.go
- binder/msgpack.go
- ctx_interface_gen.go
- docs/api/ctx.md
- ctx_test.go
- binder/msgpack_test.go
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Feature request #3224 has been created to add support for square bracket notation and comma-separated values in multipart form data in Fiber, while maintaining binary data transfer capabilities. This would bring parity with the existing form-urlencoded functionality.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Fiber currently supports square bracket notation in form data with 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. The implementation for form-urlencoded is in ctx.go (BodyParser method), while multipart form data handling needs enhancement to support this feature.
Learnt from: ReneWerner87
PR: gofiber/fiber#3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
bind_test.go (1)
Learnt from: ReneWerner87
PR: gofiber/fiber#3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
docs/api/bind.md (3)
Learnt from: hcancelik
PR: gofiber/fiber#3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-10-08T19:06:06.583Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
Learnt from: hcancelik
PR: gofiber/fiber#3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-06-15T19:26:06.401Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Fiber currently supports square bracket notation in form data with 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. The implementation for form-urlencoded is in ctx.go (BodyParser method), while multipart form data handling needs enhancement to support this feature.
🪛 LanguageTool
docs/api/bind.md
[style] ~203-~203: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...msgpack` struct tags by default. If you want to use other libraries, you may need to up...
(REP_WANT_TO_VB)
🔇 Additional comments (4)
docs/api/bind.md (1)
197-233: LGTM! Comprehensive MsgPack documentation.The new MsgPack section provides clear documentation with proper examples, signature, and usage instructions. The curl example and library reference are helpful additions.
bind_test.go (3)
882-883: LGTM! Proper msgpack struct tags added.The msgpack struct tags are correctly added to the Demo struct, maintaining consistency with other binding tag formats.
942-944: LGTM! Correct MsgPack test implementation.The MsgPack test case properly uses the correct MIME type and a valid MsgPack-encoded byte slice representing
{"name":"john"}.
1144-1167: LGTM! Well-implemented MsgPack benchmark.The new MsgPack benchmark correctly:
- Uses the proper MsgPack MIME type
- Provides a valid MsgPack byte slice
- Follows the established benchmark pattern
- Tests the intended MsgPack binding functionality
cef7e34 to
3ba0bcc
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
ctx_test.go (2)
1109-1113: Fix the incorrect assertion for MsgPack encoded output.When
AutoFormatis called withAccept: application/vnd.msgpack, it should encode the data using MsgPack, not JSON. The expected output should be MsgPack-encoded bytes, not a JSON string.Apply this diff to fix the test:
c.Request().Header.Set(HeaderAccept, MIMEApplicationMsgPack) err = c.AutoFormat("Hello, World!") require.NoError(t, err) - require.Equal(t, `"Hello, World!"`, string(c.Response().Body())) + msgpackEncoded, err := c.app.config.MsgPackEncoder("Hello, World!") + require.NoError(t, err) + require.Equal(t, msgpackEncoded, c.Response().Body())
1234-1249: Fix the incorrect assertion for MsgPack encoded output.The benchmark incorrectly expects JSON-formatted output when MsgPack encoding should be used.
Apply this diff to fix the benchmark:
var err error for b.Loop() { err = c.AutoFormat("Hello, World!") } require.NoError(b, err) - require.Equal(b, `"Hello, World!"`, string(c.Response().Body())) + msgpackEncoded, err := c.app.config.MsgPackEncoder("Hello, World!") + require.NoError(b, err) + require.Equal(b, msgpackEncoded, c.Response().Body())
🧹 Nitpick comments (2)
docs/api/bind.md (2)
44-44: Mention the commonly-usedapplication/msgpackMIME type as well.Several clients (e.g.
msgpack-cli,postman) emitapplication/msgpackrather thanapplication/vnd.msgpack. Since the implementation already accepts both values, documenting the second variant prevents confusion.-| `application/vnd.msgpack` | `msgpack` | +| `application/vnd.msgpack`, `application/msgpack` | `msgpack` |
201-203: Tweak wording to avoid repetition.-If you want to use other libraries, you may need to update the struct tags accordingly. +When using another MsgPack library, adjust the struct tags if required.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
go.modis excluded by!**/*.modgo.sumis excluded by!**/*.sum,!**/*.sum
📒 Files selected for processing (14)
app.go(3 hunks)bind.go(2 hunks)bind_test.go(4 hunks)binder/binder.go(1 hunks)binder/binder_test.go(1 hunks)binder/mapping.go(1 hunks)binder/msgpack.go(1 hunks)binder/msgpack_test.go(1 hunks)constants.go(1 hunks)ctx.go(3 hunks)ctx_interface_gen.go(4 hunks)ctx_test.go(6 hunks)docs/api/bind.md(4 hunks)docs/api/ctx.md(4 hunks)
✅ Files skipped from review due to trivial changes (1)
- constants.go
🚧 Files skipped from review as they are similar to previous changes (11)
- binder/mapping.go
- binder/binder.go
- binder/binder_test.go
- ctx.go
- app.go
- bind.go
- binder/msgpack.go
- ctx_interface_gen.go
- binder/msgpack_test.go
- docs/api/ctx.md
- bind_test.go
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Feature request #3224 has been created to add support for square bracket notation and comma-separated values in multipart form data in Fiber, while maintaining binary data transfer capabilities. This would bring parity with the existing form-urlencoded functionality.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Fiber currently supports square bracket notation in form data with 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. The implementation for form-urlencoded is in ctx.go (BodyParser method), while multipart form data handling needs enhancement to support this feature.
Learnt from: ReneWerner87
PR: gofiber/fiber#3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
ctx_test.go (17)
undefined
<retrieved_learning>
Learnt from: ReneWerner87
PR: #3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the Test method in app.go.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The project uses the testify/assert package for assertions in unit tests.
</retrieved_learning>
<retrieved_learning>
Learnt from: gaby
PR: #3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, Context() is being renamed to RequestCtx(), and UserContext() to Context() to improve clarity and align with Go's context conventions.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The project uses the testify/assert package for assertions in unit tests.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3051
File: middleware/session/session.go:215-216
Timestamp: 2024-06-30T00:38:06.580Z
Learning: Parallel tests for Session.Save already exist in the middleware/session/session_test.go file, specifically in the Test_Session_Save and Test_Session_Save_Expiration functions.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3051
File: middleware/session/session.go:215-216
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Parallel tests for Session.Save already exist in the middleware/session/session_test.go file, specifically in the Test_Session_Save and Test_Session_Save_Expiration functions.
</retrieved_learning>
<retrieved_learning>
Learnt from: gaby
PR: #3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the middleware/adaptor/adaptor.go file of the Fiber framework, when updating context handling, replacing c.Context() with c.RequestCtx() is appropriate to access the fasthttp.RequestCtx.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the Fiber framework tests, using ctx.Response.Header.Cookie may not be suitable for parsing cookies from the response header, as it requires a *Cookie and fills it rather than returning a string value; thus, manual parsing of the Set-Cookie header may be necessary.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-09-25T15:57:10.221Z
Learning: In the Fiber framework tests, using ctx.Response.Header.Cookie may not be suitable for parsing cookies from the response header, as it requires a *Cookie and fills it rather than returning a string value; thus, manual parsing of the Set-Cookie header may be necessary.
</retrieved_learning>
<retrieved_learning>
Learnt from: efectn
PR: #3162
File: hooks_test.go:228-228
Timestamp: 2024-12-13T08:14:22.851Z
Learning: In Go test files, prefer using the require methods from the testify package for assertions instead of manual comparisons and calls to t.Fatal or t.Fatalf.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3016
File: middleware/session/config.go:122-122
Timestamp: 2024-09-25T16:18:34.719Z
Learning: In DefaultErrorHandler(c *fiber.Ctx, err error), since c is a pointer to an interface, we need to dereference *c when calling interface methods like SendStatus.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3016
File: middleware/session/config.go:122-122
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In DefaultErrorHandler(c *fiber.Ctx, err error), since c is a pointer to an interface, we need to dereference *c when calling interface methods like SendStatus.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-02T23:03:31.727Z
Learning: Unit tests in this project use testify require.
</retrieved_learning>
<retrieved_learning>
Learnt from: sixcolors
PR: #3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Unit tests in this project use testify require.
</retrieved_learning>
<retrieved_learning>
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Fiber currently supports square bracket notation in form data with 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. The implementation for form-urlencoded is in ctx.go (BodyParser method), while multipart form data handling needs enhancement to support this feature.
</retrieved_learning>
<retrieved_learning>
Learnt from: efectn
PR: #3162
File: app_test.go:893-895
Timestamp: 2024-11-29T12:37:27.581Z
Learning: In the Test_App_ShutdownWithContext function in app_test.go, the clientDone channel is used to synchronize the client's request completion before proceeding, eliminating the need for additional time.Sleep calls.
</retrieved_learning>
<retrieved_learning>
Learnt from: gaby
PR: #3170
File: ctx_test.go:1721-1724
Timestamp: 2024-10-16T12:12:30.506Z
Learning: In the Go unit tests in ctx_test.go, it is acceptable to use invalid CIDR notation such as "0.0.0.1/31junk" for testing purposes.
</retrieved_learning>
docs/api/bind.md (3)
Learnt from: hcancelik
PR: gofiber/fiber#3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-10-08T19:06:06.583Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
Learnt from: hcancelik
PR: gofiber/fiber#3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-06-15T19:26:06.401Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Fiber currently supports square bracket notation in form data with 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. The implementation for form-urlencoded is in ctx.go (BodyParser method), while multipart form data handling needs enhancement to support this feature.
🪛 LanguageTool
docs/api/bind.md
[style] ~203-~203: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...msgpack` struct tags by default. If you want to use other libraries, you may need to up...
(REP_WANT_TO_VB)
🔇 Additional comments (6)
docs/api/bind.md (1)
52-53: Struct tag now correct – looks good.The
msgpack:"pass"tag fixes the earlier mismatch and aligns with the other formats.ctx_test.go (5)
996-1000: LGTM!The test correctly verifies content negotiation behavior for MsgPack format.
1073-1086: LGTM!The benchmark correctly measures MsgPack format selection performance.
1164-1176: LGTM!The test correctly verifies MsgPack encoding of structs with proper byte-level assertions.
3748-3804: LGTM!Comprehensive test coverage for the MsgPack method, including edge cases and custom encoder support.
3806-3826: LGTM!The benchmark correctly measures MsgPack encoding performance with proper assertions.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3565 +/- ##
==========================================
+ Coverage 90.91% 90.95% +0.03%
==========================================
Files 110 111 +1
Lines 11067 11115 +48
==========================================
+ Hits 10062 10110 +48
Misses 753 753
Partials 252 252
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@hotrungnhan Don't forget to update the |
|
@gaby I've update the docs, you guy can review now. |
gaby
left a comment
There was a problem hiding this comment.
Overall looks good, just a small comment.
|
@ksw2000 @gofiber/maintainers @coderabbitai |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 3359 @ReneWerner87, excellent point about dependency management! Here are several approaches to solve this issue: Solution Options1. Interface-based Lazy Loading (Recommended)// In app.go - no direct imports
type MsgPackMarshal func(v any) ([]byte, error)
type MsgPackUnmarshal func(data []byte, v any) error
type Config struct {
// Remove direct function assignments, use interfaces
MsgPackEncoder MsgPackMarshal
MsgPackDecoder MsgPackUnmarshal
}
func New(config ...Config) *App {
// Don't set defaults here - only when first used
if cfg.MsgPackEncoder == nil {
cfg.MsgPackEncoder = getDefaultMsgPackEncoder() // lazy load
}
}
// In separate file: msgpack_default.go
func getDefaultMsgPackEncoder() MsgPackMarshal {
return msgpack.Marshal // import only happens here
}2. Build Tags Approach// msgpack_enabled.go
//go:build msgpack
import "github.com/shamaton/msgpack/v2"
// msgpack_disabled.go
//go:build !msgpack
func init() {
// Provide stub implementations or return errors
}3. Registry Pattern (Like Middleware)// In separate package: fiber/msgpack
func init() {
fiber.RegisterEncoder("msgpack", msgpack.Marshal)
fiber.RegisterDecoder("msgpack", msgpack.Unmarshal)
}
// Users import: _ "github.com/gofiber/fiber/v3/msgpack"4. Runtime Registration// In app.go
var (
msgPackEncoder MsgPackMarshal
msgPackDecoder MsgPackUnmarshal
)
func RegisterMsgPack(encoder MsgPackMarshal, decoder MsgPackUnmarshal) {
msgPackEncoder = encoder
msgPackDecoder = decoder
}
// In separate package or user code
import "github.com/shamaton/msgpack/v2"
func init() {
fiber.RegisterMsgPack(msgpack.Marshal, msgpack.Unmarshal)
}The Interface-based Lazy Loading approach would be most consistent with Fiber's current architecture while solving the dependency issue. Users who need MsgPack would only pull the dependency when they actually configure or use the feature. Would you prefer to explore one of these approaches further? 🐰 Hopping toward cleaner dependencies! 🧠 Learnings used |
…ethods and clean up documentation
it ready now, do i have to squash commit, or it will does automatically ? |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
docs/api/ctx.md (2)
1870-1879: Confirm code-block terminationEnsure the triple-back-tick that closes the
go title="Example"block is present before the standalone output comments (Content-Type / hex dump). Missing it will break the remainder of the page.
1890-1892: Output comment formattingFor consistency with JSON / CBOR examples, put the Content-Type and hex dump comments inside the example block or both outside – but not split. Pick one style to avoid confusion.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
go.modis excluded by!**/*.modgo.sumis excluded by!**/*.sum,!**/*.sum
📒 Files selected for processing (16)
app.go(3 hunks)bind.go(2 hunks)bind_test.go(5 hunks)binder/binder.go(1 hunks)binder/binder_test.go(1 hunks)binder/msgpack.go(1 hunks)binder/msgpack_test.go(1 hunks)constants.go(1 hunks)ctx.go(3 hunks)ctx_interface_gen.go(1 hunks)ctx_test.go(8 hunks)docs/api/bind.md(7 hunks)docs/api/ctx.md(4 hunks)docs/api/fiber.md(1 hunks)docs/guide/advance-format.md(1 hunks)docs/whats_new.md(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (15)
- constants.go
- docs/api/fiber.md
- binder/binder_test.go
- ctx_interface_gen.go
- binder/binder.go
- docs/whats_new.md
- bind.go
- docs/guide/advance-format.md
- ctx.go
- app.go
- binder/msgpack_test.go
- docs/api/bind.md
- bind_test.go
- binder/msgpack.go
- ctx_test.go
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ksw2000
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2025-07-08T13:41:20.627Z
Learning: ksw2000 suggests implementing a pluggable encoder/decoder registry system in Fiber instead of hardcoding all encoders in app.config. This would solve dependency management issues by allowing users to opt-in only to the formats they need, keeping JSON and XML as defaults while making CBOR and MsgPack explicit registrations.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Feature request #3224 has been created to add support for square bracket notation and comma-separated values in multipart form data in Fiber, while maintaining binary data transfer capabilities. This would bring parity with the existing form-urlencoded functionality.
Learnt from: ReneWerner87
PR: gofiber/fiber#3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Fiber currently supports square bracket notation in form data with 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. The implementation for form-urlencoded is in ctx.go (BodyParser method), while multipart form data handling needs enhancement to support this feature.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
docs/api/ctx.md (12)
Learnt from: gaby
PR: gofiber/fiber#3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.
Learnt from: gaby
PR: gofiber/fiber#3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.
Learnt from: ReneWerner87
PR: gofiber/fiber#3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-09-25T15:57:10.221Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.
Learnt from: hcancelik
PR: gofiber/fiber#3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-06-15T19:26:06.401Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
Learnt from: hcancelik
PR: gofiber/fiber#3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-10-08T19:06:06.583Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/config.go:122-122
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In `DefaultErrorHandler(c *fiber.Ctx, err error)`, since `c` is a pointer to an interface, we need to dereference `*c` when calling interface methods like `SendStatus`.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/config.go:122-122
Timestamp: 2024-09-25T16:18:34.719Z
Learning: In `DefaultErrorHandler(c *fiber.Ctx, err error)`, since `c` is a pointer to an interface, we need to dereference `*c` when calling interface methods like `SendStatus`.
Learnt from: mdelapenya
PR: gofiber/fiber#3434
File: docs/api/services.md:39-43
Timestamp: 2025-05-07T13:07:33.899Z
Learning: When documenting Go interface methods in the Fiber project, avoid showing method signatures with the interface type as the receiver (e.g., `func (d *Service) Method()`) since interfaces cannot be used as receivers in Go. Instead, show just the method signature without a receiver or use a placeholder implementation name.
Learnt from: ksw2000
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2025-07-08T13:41:20.627Z
Learning: ksw2000 suggests implementing a pluggable encoder/decoder registry system in Fiber instead of hardcoding all encoders in app.config. This would solve dependency management issues by allowing users to opt-in only to the formats they need, keeping JSON and XML as defaults while making CBOR and MsgPack explicit registrations.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Fiber currently supports square bracket notation in form data with 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. The implementation for form-urlencoded is in ctx.go (BodyParser method), while multipart form data handling needs enhancement to support this feature.
🪛 LanguageTool
docs/api/ctx.md
[grammar] ~1845-~1845: Ensure spelling is correct
Context: ...ack A Replacement for JSON to effiently transfer data between microservices or ...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🔇 Additional comments (4)
docs/api/ctx.md (4)
1368-1374: Table re-flow looks goodThe new column descriptions align correctly with Docusaurus’ pipe-table syntax; no rendering issues spotted.
1474-1477: 👍 Added MIME type to AutoFormat list
application/vnd.msgpackis now advertised alongside the existing formats – nice catch.
1506-1509: Hex dump very likely truncatedThe MsgPack bytes end abruptly at
… 64 6f 65without closing the map. Earlier feedback flagged the same issue.
Please regenerate the dump or replace it with an ellipsis.-// => 82 a4 6e 61 6d 65 a4 6a 6f 68 6e a4 70 61 73 73 a3 64 6f 65 +// => 82 A4 6E 61 6D 65 A4 6A 6F 68 6E A4 70 61 73 73 A3 64 6F 65 14 +// ↑ complete sequence (or add “…” if space is a concern)
1853-1856: Capitalisation of function receiverAll other signatures use
(c fiber.Ctx). Current text has(c fiber.Ctx)– good. No change needed.
|
Squash is done automatically |
|
@ReneWerner87 can you approve the pipeline once again ? |
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
binder/msgpack_test.go (2)
70-70: Fix incorrect benchmark loop syntax.The
b.Loop()method doesn't exist in Go's testing package.Apply this diff to fix the benchmark loop:
- for b.Loop() { + for i := 0; i < b.N; i++ {
80-86: Remove assertions from benchmark for accurate performance measurement.Assertions inside the benchmark loop can affect performance measurements and should be moved outside the loop.
Consider moving these assertions outside the benchmark loop:
var user User var err error + + // Pre-validate the benchmark will work correctly + testUser := User{} + testErr := binder.Bind([]byte{ + 0x83, 0xa4, 0x6e, 0x61, 0x6d, 0x65, 0xa4, 0x6a, 0x6f, 0x68, 0x6e, 0xa3, 0x61, 0x67, 0x65, 0x2a, + 0xa5, 0x70, 0x6f, 0x73, 0x74, 0x73, 0x93, 0xa5, 0x70, 0x6f, 0x73, 0x74, 0x31, 0xa5, 0x70, 0x6f, + 0x73, 0x74, 0x32, 0xa5, 0x70, 0x6f, 0x73, 0x74, 0x33, + }, &testUser) + require.NoError(b, testErr) + for i := 0; i < b.N; i++ { err = binder.Bind([]byte{ 0x83, 0xa4, 0x6e, 0x61, 0x6d, 0x65, 0xa4, 0x6a, 0x6f, 0x68, 0x6e, 0xa3, 0x61, 0x67, 0x65, 0x2a, 0xa5, 0x70, 0x6f, 0x73, 0x74, 0x73, 0x93, 0xa5, 0x70, 0x6f, 0x73, 0x74, 0x31, 0xa5, 0x70, 0x6f, 0x73, 0x74, 0x32, 0xa5, 0x70, 0x6f, 0x73, 0x74, 0x33, }, &user) } - - require.NoError(b, err) - require.Equal(b, "john", user.Name) - require.Equal(b, 42, user.Age) - require.Len(b, user.Posts, 3) - require.Equal(b, "post1", user.Posts[0]) - require.Equal(b, "post2", user.Posts[1]) - require.Equal(b, "post3", user.Posts[2]) + + // Final validation after benchmark + require.NoError(b, err)
🧹 Nitpick comments (2)
binder/msgpack_test.go (2)
113-113: Fix grammatical error in panic message validation.There's a grammatical error in the expected panic message.
Apply this diff to fix the grammar:
- require.Contains(t, r, "Must explicits setup Msgpack") + require.Contains(t, r, "Must explicitly setup Msgpack")
126-126: Fix grammatical error in panic message validation.There's a grammatical error in the expected panic message (same as line 113).
Apply this diff to fix the grammar:
- require.Contains(t, r, "Must explicits setup Msgpack") + require.Contains(t, r, "Must explicitly setup Msgpack")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
bind_test.go(5 hunks)binder/msgpack_test.go(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- bind_test.go
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ksw2000
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2025-07-08T13:41:20.627Z
Learning: ksw2000 suggests implementing a pluggable encoder/decoder registry system in Fiber instead of hardcoding all encoders in app.config. This would solve dependency management issues by allowing users to opt-in only to the formats they need, keeping JSON and XML as defaults while making CBOR and MsgPack explicit registrations.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Feature request #3224 has been created to add support for square bracket notation and comma-separated values in multipart form data in Fiber, while maintaining binary data transfer capabilities. This would bring parity with the existing form-urlencoded functionality.
Learnt from: ReneWerner87
PR: gofiber/fiber#3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:28:36.011Z
Learning: Fiber currently supports square bracket notation in form data with 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. The implementation for form-urlencoded is in ctx.go (BodyParser method), while multipart form data handling needs enhancement to support this feature.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
Learnt from: ReneWerner87
PR: gofiber/fiber#0
File: :0-0
Timestamp: 2024-12-01T10:30:20.597Z
Learning: In Fiber, square bracket notation in form data is currently supported only with 'application/x-www-form-urlencoded' content type, but not with multipart form data. This limitation affects parsing nested structures in multipart form data.
binder/msgpack_test.go (8)
Learnt from: efectn
PR: gofiber/fiber#3162
File: hooks_test.go:228-228
Timestamp: 2024-12-13T08:14:22.851Z
Learning: In Go test files, prefer using the `require` methods from the `testify` package for assertions instead of manual comparisons and calls to `t.Fatal` or `t.Fatalf`.
Learnt from: sixcolors
PR: gofiber/fiber#2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The project uses the testify/assert package for assertions in unit tests.
Learnt from: sixcolors
PR: gofiber/fiber#2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The project uses the testify/assert package for assertions in unit tests.
Learnt from: sixcolors
PR: gofiber/fiber#3051
File: middleware/session/session.go:215-216
Timestamp: 2024-06-30T00:38:06.580Z
Learning: Parallel tests for `Session.Save` already exist in the `middleware/session/session_test.go` file, specifically in the `Test_Session_Save` and `Test_Session_Save_Expiration` functions.
Learnt from: sixcolors
PR: gofiber/fiber#3051
File: middleware/session/session.go:215-216
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Parallel tests for `Session.Save` already exist in the `middleware/session/session_test.go` file, specifically in the `Test_Session_Save` and `Test_Session_Save_Expiration` functions.
Learnt from: ReneWerner87
PR: gofiber/fiber#3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-02T23:03:31.727Z
Learning: Unit tests in this project use testify require.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Unit tests in this project use testify require.
🔇 Additional comments (2)
binder/msgpack_test.go (2)
10-53: Comprehensive test coverage looks good.The test properly validates MsgPack binding functionality with complex nested structures and verifies the Reset() method behavior.
89-106: Proper panic testing implementation.The tests correctly verify that the unimplemented MsgPack functions panic as expected when called without proper setup.
|
@gaby @ReneWerner87 Plz approve one more time, I’ve fixed the benchmark and added some additional documentation. |
|
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 |
Description
Fixes # (issue)
Changes introduced
List the new features or adjustments introduced in this pull request:
/docs/api/bind.mdand/docs/api/ctx.mdto include MsgPack binding examples and context method usage.c.MsgPack()and binder functionality.c.JSON(),c.XML(), andc.CBOR()methods.Type of change
Please delete options that are not relevant.
Checklist
Before you submit your pull request, please make sure you meet these requirements:
/docs/directory for Fiber's documentation.Commit formatting
Please use emojis in commit messages for an easy way to identify the purpose or intention of a commit. Check out the emoji cheatsheet here: CONTRIBUTING.md
✅ Used emoji in commit message:
🔥 feat: Add support for MsgpackTechnical Implementation Details
Key Changes Made:
New Files Added:
binder/msgpack.go- MsgPack binder implementationbinder/msgpack_test.go- Comprehensive test suite for MsgPack bindingCore Framework Changes:
MIMEApplicationMsgPack = "application/vnd.msgpack"github.com/shamaton/msgpack/v2 v2.2.3for MsgPack serializationgithub.com/gofiber/utils/v2to support MsgPack typesContext API Enhancements:
c.MsgPack(data any, ctype ...string) errorfor sending MsgPack responsesc.Format()method for automatic content type selectionConfiguration Options:
msgpack.Marshal)msgpack.Unmarshal)Binder Integration:
Files Modified:
app.go- Added MsgPack encoder/decoder configurationbind.go- Added MsgPack binding supportbind_test.go- Added comprehensive MsgPack binding testsbinder/binder.go- Registered MsgPack binderbinder/mapping.go- Updated content type mappingconstants.go- Added MsgPack MIME type constantctx.go- Added MsgPack context methodctx_interface_gen.go- Updated interface generation for MsgPack methodctx_test.go- Added comprehensive MsgPack context testsdocs/api/bind.md- Updated binding documentationdocs/api/ctx.md- Updated context documentationgo.mod&go.sum- Added MsgPack dependencyPerformance Benefits:
Usage Examples:
Sending MsgPack Response:
Binding MsgPack Request:
Content Negotiation: