Home / Function/ redirectTrailingSlash() — gin Function Reference

redirectTrailingSlash() — gin Function Reference

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

Function go CoreEngine Routing calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  a3ad729e_6252_c42c_5a77_556e798082aa["redirectTrailingSlash()"]
  466cd829_a704_bc42_f2bb_a07bb48488bd["handleHTTPRequest()"]
  466cd829_a704_bc42_f2bb_a07bb48488bd -->|calls| a3ad729e_6252_c42c_5a77_556e798082aa
  a1bba89b_7672_0e18_2963_a802c9b0c8f5["sanitizePathChars()"]
  a3ad729e_6252_c42c_5a77_556e798082aa -->|calls| a1bba89b_7672_0e18_2963_a802c9b0c8f5
  0c112b3d_e60f_10d6_31b8_9f700dd18e61["redirectRequest()"]
  a3ad729e_6252_c42c_5a77_556e798082aa -->|calls| 0c112b3d_e60f_10d6_31b8_9f700dd18e61
  style a3ad729e_6252_c42c_5a77_556e798082aa fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

gin.go lines 781–795

func redirectTrailingSlash(c *Context) {
	req := c.Request
	p := req.URL.Path
	if prefix := path.Clean(c.Request.Header.Get("X-Forwarded-Prefix")); prefix != "." {
		prefix = sanitizePathChars(prefix)
		prefix = removeRepeatedChar(prefix, '/')

		p = prefix + "/" + req.URL.Path
	}
	req.URL.Path = p + "/"
	if length := len(p); length > 1 && p[length-1] == '/' {
		req.URL.Path = p[:length-1]
	}
	redirectRequest(c)
}

Domain

Subdomains

Frequently Asked Questions

What does redirectTrailingSlash() do?
redirectTrailingSlash() is a function in the gin codebase.
What does redirectTrailingSlash() call?
redirectTrailingSlash() calls 2 function(s): redirectRequest, sanitizePathChars.
What calls redirectTrailingSlash()?
redirectTrailingSlash() is called by 1 function(s): handleHTTPRequest.

Analyze Your Own Codebase

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

Try Supermodel Free