File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -337,8 +337,22 @@ func initializeDXClusters(ctx context.Context, cfg *config.Config) ([]*cluster.C
337337func setupHTTPRouter (cfg * config.Config ) * gin.Engine {
338338 gin .SetMode (gin .ReleaseMode )
339339 router := gin .New ()
340- router .RedirectTrailingSlash = true
341- router .RedirectFixedPath = true
340+
341+ // Normalize paths: remove trailing slashes and collapse multiple slashes
342+ router .Use (func (c * gin.Context ) {
343+ path := c .Request .URL .Path
344+ // Collapse multiple slashes
345+ for strings .Contains (path , "//" ) {
346+ path = strings .ReplaceAll (path , "//" , "/" )
347+ }
348+ // Remove trailing slash (except for root)
349+ if len (path ) > 1 && strings .HasSuffix (path , "/" ) {
350+ path = strings .TrimSuffix (path , "/" )
351+ }
352+ c .Request .URL .Path = path
353+ c .Next ()
354+ })
355+
342356 router .Use (logging .GinRecovery ())
343357 router .Use (logging .GinLogger ())
344358
You can’t perform that action at this time.
0 commit comments