We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
type tHeader struct { Limit int `header:"limit"` Limit2 int `json:"limit"` }
If my http request header has limit , I want only math tag: "header:"limi"
func TestHeaderBinding(t *testing.T) { h := Header assert.Equal(t, "header", h.Name()) type tHeader struct { Limit int `header:"limit"` Limit2 int `json:"limit"` } var theader tHeader req := requestWithBody(http.MethodGet, "/", "") req.Header.Add("limit", "1000") require.NoError(t, h.Bind(req, &theader)) assert.Equal(t, 1000, theader.Limit) assert.Equal(t, 0, theader.Limit2) req = requestWithBody(http.MethodGet, "/", "") req.Header.Add("fail", `{fail:fail}`) type failStruct struct { Fail map[string]any `header:"fail"` } err := h.Bind(req, &failStruct{}) require.Error(t, err) }
The text was updated successfully, but these errors were encountered:
open ai has been give answer:
if vKind != reflect.Struct || !field.Anonymous { if _, exists := field.Tag.Lookup(tag); exists { ok, err := tryToSetValue(value, field, setter, tag) if err != nil { return false, err } if ok { return true, nil } } }
Sorry, something went wrong.
No branches or pull requests
Description
If my http request header has limit , I want only math tag: "header:"limi"
Expectations
The text was updated successfully, but these errors were encountered: