-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: [#515] Input* methods of http.Request support retrieve data from query and route #111
Conversation
…m query and route
WalkthroughThe changes in this pull request involve significant modifications to the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
context_request.go
Outdated
"fmt" | ||
"github.com/goravel/framework/support/str" |
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.
Sort it
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.
Thanks, done.
And test failed |
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
context_request.go (1)
298-317
: Consider adding documentation for the precedence order.The implementation is solid and handles array inputs well. Consider adding a comment documenting the precedence order (httpBody -> query -> route -> default) to help future maintainers.
+// InputArray retrieves an array value from the request in the following order: +// 1. HTTP body +// 2. Query parameters +// 3. Route parameters (comma-separated) +// 4. Default value func (r *ContextRequest) InputArray(key string, defaultValue ...[]string) []string {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
context_request.go
(2 hunks)context_request_test.go
(5 hunks)
🔇 Additional comments (6)
context_request.go (3)
281-293
: LGTM! Well-structured input retrieval implementation.
The implementation properly handles the precedence order and includes appropriate existence checks for query and route parameters.
325-333
: LGTM! Consistent with array handling approach.
The implementation maintains consistency with InputArray by returning empty maps instead of nil, which is a good practice for avoiding nil pointer dereferences.
281-333
: Verify test failures mentioned in PR comments.
The implementation looks solid, but there are reported test failures that need to be addressed.
context_request_test.go (3)
655-662
: LGTM! Good test coverage for empty string handling.
The test properly verifies that empty strings are preserved rather than being replaced by default values.
Line range hint 675-685
: LGTM! Proper verification of default value handling.
The test effectively verifies that default values are returned when no input is provided.
Line range hint 791-803
: LGTM! Comprehensive testing of empty collection handling.
The tests properly verify that empty arrays and maps are handled correctly, maintaining consistency with the implementation's approach of avoiding nil returns.
Also applies to: 901-909
📑 Description
Closes goravel/goravel#515
Summary by CodeRabbit
New Features
Bug Fixes
Tests
✅ Checks