Test_Bind_Cookie_WithSetParserDecoder() — fiber Function Reference
Architecture documentation for the Test_Bind_Cookie_WithSetParserDecoder() function in bind_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 1d32ec80_f188_40bf_c2c2_d67268579bed["Test_Bind_Cookie_WithSetParserDecoder()"] 55065b01_f5dc_4e53_5a74_5ecc7aca8f52["bind_test.go"] 1d32ec80_f188_40bf_c2c2_d67268579bed -->|defined in| 55065b01_f5dc_4e53_5a74_5ecc7aca8f52 style 1d32ec80_f188_40bf_c2c2_d67268579bed fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
bind_test.go lines 1610–1662
func Test_Bind_Cookie_WithSetParserDecoder(t *testing.T) {
type NonRFCTime time.Time
nonRFCConverter := func(value string) reflect.Value {
if v, err := time.Parse("2006-01-02", value); err == nil {
return reflect.ValueOf(v)
}
return reflect.Value{}
}
nonRFCTime := binder.ParserType{
CustomType: NonRFCTime{},
Converter: nonRFCConverter,
}
binder.SetParserDecoder(binder.ParserConfig{
IgnoreUnknownKeys: true,
ParserType: []binder.ParserType{nonRFCTime},
ZeroEmpty: true,
SetAliasTag: "cerez",
})
app := New()
c := app.AcquireCtx(&fasthttp.RequestCtx{})
type NonRFCTimeInput struct {
Date NonRFCTime `cerez:"date"`
Title string `cerez:"title"`
Body string `cerez:"body"`
}
c.Request().SetBody([]byte(``))
c.Request().Header.SetContentType("")
r := new(NonRFCTimeInput)
c.Request().Header.SetCookie("Date", "2021-04-10")
c.Request().Header.SetCookie("Title", "CustomDateTest")
c.Request().Header.SetCookie("Body", "October")
require.NoError(t, c.Bind().Cookie(r))
require.Equal(t, "CustomDateTest", r.Title)
date := fmt.Sprintf("%v", r.Date)
require.Equal(t, "{0 63753609600 <nil>}", date)
require.Equal(t, "October", r.Body)
c.Request().Header.SetCookie("Title", "")
r = &NonRFCTimeInput{
Title: "Existing title",
Body: "Existing Body",
}
require.NoError(t, c.Bind().Cookie(r))
require.Empty(t, r.Title)
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Bind_Cookie_WithSetParserDecoder() do?
Test_Bind_Cookie_WithSetParserDecoder() is a function in the fiber codebase, defined in bind_test.go.
Where is Test_Bind_Cookie_WithSetParserDecoder() defined?
Test_Bind_Cookie_WithSetParserDecoder() is defined in bind_test.go at line 1610.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free