Test_Ctx_Type() — fiber Function Reference
Architecture documentation for the Test_Ctx_Type() function in ctx_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD add38597_9671_6785_0d75_d0cebffbf2bc["Test_Ctx_Type()"] 7b3d4933_5ae3_f84d_ff6d_0cb34e268026["ctx_test.go"] add38597_9671_6785_0d75_d0cebffbf2bc -->|defined in| 7b3d4933_5ae3_f84d_ff6d_0cb34e268026 style add38597_9671_6785_0d75_d0cebffbf2bc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
ctx_test.go lines 7342–7382
func Test_Ctx_Type(t *testing.T) {
t.Parallel()
app := New()
c := app.AcquireCtx(&fasthttp.RequestCtx{})
c.Type(".json")
require.Equal(t, "application/json; charset=utf-8", string(c.Response().Header.Peek("Content-Type")))
c.Type("json", "utf-8")
require.Equal(t, "application/json; charset=utf-8", string(c.Response().Header.Peek("Content-Type")))
c.Type(".html")
require.Equal(t, "text/html; charset=utf-8", string(c.Response().Header.Peek("Content-Type")))
c.Type("html", "utf-8")
require.Equal(t, "text/html; charset=utf-8", string(c.Response().Header.Peek("Content-Type")))
// Test other text types get UTF-8 by default
c.Type("txt")
require.Equal(t, "text/plain; charset=utf-8", string(c.Response().Header.Peek("Content-Type")))
c.Type("css")
require.Equal(t, "text/css; charset=utf-8", string(c.Response().Header.Peek("Content-Type")))
c.Type("js")
require.Equal(t, "text/javascript; charset=utf-8", string(c.Response().Header.Peek("Content-Type")))
c.Type("xml")
require.Equal(t, "application/xml; charset=utf-8", string(c.Response().Header.Peek("Content-Type")))
// Test binary types don't get charset
c.Type("png")
require.Equal(t, "image/png", string(c.Response().Header.Peek("Content-Type")))
c.Type("pdf")
require.Equal(t, "application/pdf", string(c.Response().Header.Peek("Content-Type")))
// Test custom charset override
c.Type("html", "iso-8859-1")
require.Equal(t, "text/html; charset=iso-8859-1", string(c.Response().Header.Peek("Content-Type")))
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Ctx_Type() do?
Test_Ctx_Type() is a function in the fiber codebase, defined in ctx_test.go.
Where is Test_Ctx_Type() defined?
Test_Ctx_Type() is defined in ctx_test.go at line 7342.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free