TestLimiterFixedPropagatesRequestContextToStorage() — fiber Function Reference
Architecture documentation for the TestLimiterFixedPropagatesRequestContextToStorage() function in limiter_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD b4c4e898_37f6_b5aa_95ab_209eb58a3653["TestLimiterFixedPropagatesRequestContextToStorage()"] 0509da96_221e_0d0d_fe2e_f2e2e3695b6f["limiter_test.go"] b4c4e898_37f6_b5aa_95ab_209eb58a3653 -->|defined in| 0509da96_221e_0d0d_fe2e_f2e2e3695b6f ceee159b_ff25_aa39_7380_65ce5ea23643["newContextRecorderLimiterStorage()"] b4c4e898_37f6_b5aa_95ab_209eb58a3653 -->|calls| ceee159b_ff25_aa39_7380_65ce5ea23643 7f532e95_c67c_e1fb_201a_4523be5937f5["contextWithMarker()"] b4c4e898_37f6_b5aa_95ab_209eb58a3653 -->|calls| 7f532e95_c67c_e1fb_201a_4523be5937f5 418b866d_b436_722f_b08d_9990bcc9fd7d["canceledContextWithMarker()"] b4c4e898_37f6_b5aa_95ab_209eb58a3653 -->|calls| 418b866d_b436_722f_b08d_9990bcc9fd7d style b4c4e898_37f6_b5aa_95ab_209eb58a3653 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/limiter/limiter_test.go lines 254–318
func TestLimiterFixedPropagatesRequestContextToStorage(t *testing.T) {
t.Parallel()
storage := newContextRecorderLimiterStorage()
app := fiber.New()
app.Use(func(c fiber.Ctx) error {
path := c.Path()
if path == "/normal" {
c.SetContext(contextWithMarker("fixed-normal"))
}
if path == "/rollback" {
c.SetContext(canceledContextWithMarker("fixed-rollback"))
}
return c.Next()
})
app.Use(New(Config{
Storage: storage,
Max: 1,
Expiration: time.Minute,
SkipSuccessfulRequests: true,
KeyGenerator: func(c fiber.Ctx) string {
return c.Path()
},
LimiterMiddleware: FixedWindow{},
}))
app.Get("/:mode", func(c fiber.Ctx) error {
return c.SendString("ok")
})
for _, path := range []string{"/normal", "/rollback"} {
resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, path, http.NoBody))
require.NoError(t, err)
require.Equal(t, fiber.StatusOK, resp.StatusCode)
}
gets := storage.recordedGets()
require.Len(t, gets, 4)
sets := storage.recordedSets()
require.Len(t, sets, 4)
verifyRecords := func(t *testing.T, records []contextRecord, key, wantValue string, wantCanceled bool) {
t.Helper()
var matched []contextRecord
for _, rec := range records {
if rec.key == key {
matched = append(matched, rec)
}
}
require.Len(t, matched, 2)
for _, rec := range matched {
require.Equal(t, wantValue, rec.value)
require.Equal(t, wantCanceled, rec.canceled)
}
}
verifyRecords(t, gets, "/normal", "fixed-normal", false)
verifyRecords(t, gets, "/rollback", "fixed-rollback", true)
verifyRecords(t, sets, "/normal", "fixed-normal", false)
verifyRecords(t, sets, "/rollback", "fixed-rollback", true)
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does TestLimiterFixedPropagatesRequestContextToStorage() do?
TestLimiterFixedPropagatesRequestContextToStorage() is a function in the fiber codebase, defined in middleware/limiter/limiter_test.go.
Where is TestLimiterFixedPropagatesRequestContextToStorage() defined?
TestLimiterFixedPropagatesRequestContextToStorage() is defined in middleware/limiter/limiter_test.go at line 254.
What does TestLimiterFixedPropagatesRequestContextToStorage() call?
TestLimiterFixedPropagatesRequestContextToStorage() calls 3 function(s): canceledContextWithMarker, contextWithMarker, newContextRecorderLimiterStorage.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free