Skip to content

Commit c298e30

Browse files
vishrclaude
andcommitted
Fix misleading Context.Bind documentation comment
Addresses issue #2382 by correcting the confusing comment on Context.Bind that did not accurately describe the actual binding behavior. **Problem:** The previous comment said "Bind binds path params, query params and the request body" which was incomplete and misleading because: - It didn't explain the binding ORDER (path → query → body) - It didn't mention that later steps can OVERRIDE earlier values - It didn't specify that query params are only bound for GET/DELETE/HEAD - It didn't reference single-source binding methods **Solution:** Updated the comment to clearly explain: - The exact binding order (1) path params, 2) query params, 3) body) - Override behavior between steps - HTTP method-specific behavior for query params - References to single-source binding methods - Content-Type handling for body binding This prevents confusion for developers who might expect different behavior from Context.Bind() based on the previous misleading documentation. Fixes #2382 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent f1ebc67 commit c298e30

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

context.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,11 @@ type Context interface {
102102
// Set saves data in the context.
103103
Set(key string, val interface{})
104104

105-
// Bind binds path params, query params and the request body into provided type `i`. The default binder
106-
// binds body based on Content-Type header.
105+
// Bind binds data from multiple sources to the provided type `i` in this order:
106+
// 1) path parameters, 2) query parameters (for GET/DELETE/HEAD only), 3) request body.
107+
// Each step can override values from the previous step. For single source binding use
108+
// BindPathParams, BindQueryParams, BindHeaders, or BindBody directly.
109+
// The default binder handles body based on Content-Type header.
107110
Bind(i interface{}) error
108111

109112
// Validate validates provided `i`. It is usually called after `Context#Bind()`.

0 commit comments

Comments
 (0)