Home / Function/ Test_CacheStorage_CustomHeaders() — fiber Function Reference

Test_CacheStorage_CustomHeaders() — fiber Function Reference

Architecture documentation for the Test_CacheStorage_CustomHeaders() function in cache_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  b8a9830d_0462_d691_83cb_712dc70abafa["Test_CacheStorage_CustomHeaders()"]
  8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"]
  b8a9830d_0462_d691_83cb_712dc70abafa -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656
  style b8a9830d_0462_d691_83cb_712dc70abafa fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/cache/cache_test.go lines 1367–1392

func Test_CacheStorage_CustomHeaders(t *testing.T) {
	t.Parallel()
	app := fiber.New()
	app.Use(New(Config{
		Storage:  memory.New(),
		MaxBytes: 10 * 1024 * 1024,
	}))

	app.Get("/", func(c fiber.Ctx) error {
		c.Response().Header.Set("Content-Type", "text/xml")
		c.Response().Header.Set("Content-Encoding", "utf8")
		return c.Send([]byte("<xml><value>Test</value></xml>"))
	})

	resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
	require.NoError(t, err)
	body, err := io.ReadAll(resp.Body)
	require.NoError(t, err)

	respCached, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
	require.NoError(t, err)
	bodyCached, err := io.ReadAll(respCached.Body)
	require.NoError(t, err)
	require.True(t, bytes.Equal(body, bodyCached))
	require.NotEmpty(t, respCached.Header.Get(fiber.HeaderCacheControl))
}

Subdomains

Frequently Asked Questions

What does Test_CacheStorage_CustomHeaders() do?
Test_CacheStorage_CustomHeaders() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_CacheStorage_CustomHeaders() defined?
Test_CacheStorage_CustomHeaders() is defined in middleware/cache/cache_test.go at line 1367.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free