Home / Function/ TestRouteRedirectFixedPath() — gin Function Reference

TestRouteRedirectFixedPath() — gin Function Reference

Architecture documentation for the TestRouteRedirectFixedPath() function in routes_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  d4a6c451_0659_7aa7_f5da_b05392a26203["TestRouteRedirectFixedPath()"]
  45929e18_70ca_7c55_01e0_596be99dd824["routes_test.go"]
  d4a6c451_0659_7aa7_f5da_b05392a26203 -->|defined in| 45929e18_70ca_7c55_01e0_596be99dd824
  9785c910_0083_377a_37b6_92b299e0e32d["PerformRequest()"]
  d4a6c451_0659_7aa7_f5da_b05392a26203 -->|calls| 9785c910_0083_377a_37b6_92b299e0e32d
  style d4a6c451_0659_7aa7_f5da_b05392a26203 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

routes_test.go lines 249–274

func TestRouteRedirectFixedPath(t *testing.T) {
	router := New()
	router.RedirectFixedPath = true
	router.RedirectTrailingSlash = false

	router.GET("/path", func(c *Context) {})
	router.GET("/Path2", func(c *Context) {})
	router.POST("/PATH3", func(c *Context) {})
	router.POST("/Path4/", func(c *Context) {})

	w := PerformRequest(router, http.MethodGet, "/PATH")
	assert.Equal(t, "/path", w.Header().Get("Location"))
	assert.Equal(t, http.StatusMovedPermanently, w.Code)

	w = PerformRequest(router, http.MethodGet, "/path2")
	assert.Equal(t, "/Path2", w.Header().Get("Location"))
	assert.Equal(t, http.StatusMovedPermanently, w.Code)

	w = PerformRequest(router, http.MethodPost, "/path3")
	assert.Equal(t, "/PATH3", w.Header().Get("Location"))
	assert.Equal(t, http.StatusTemporaryRedirect, w.Code)

	w = PerformRequest(router, http.MethodPost, "/path4")
	assert.Equal(t, "/Path4/", w.Header().Get("Location"))
	assert.Equal(t, http.StatusTemporaryRedirect, w.Code)
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does TestRouteRedirectFixedPath() do?
TestRouteRedirectFixedPath() is a function in the gin codebase, defined in routes_test.go.
Where is TestRouteRedirectFixedPath() defined?
TestRouteRedirectFixedPath() is defined in routes_test.go at line 249.
What does TestRouteRedirectFixedPath() call?
TestRouteRedirectFixedPath() calls 1 function(s): PerformRequest.

Analyze Your Own Codebase

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

Try Supermodel Free