Skip to content

Commit

Permalink
minor: solved full path error on logging (part III)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralvarezdev committed Feb 1, 2025
1 parent e6db3d1 commit f1af465
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions http/route/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,12 @@ func NewGroup(

// Check the base router path
var fullPath string
if baseRouter.fullPath[len(baseRouter.fullPath)-1] == '/' {
fullPath = baseRouter.fullPath + relativePath
if relativePath == "/" && baseRouter.fullPath == "/" {
fullPath = "/"
} else if baseRouter.fullPath[len(baseRouter.fullPath)-1] == '/' {
fullPath = baseRouter.fullPath + relativePath[1:]
} else {
fullPath = baseRouter.fullPath + "/" + relativePath
fullPath = baseRouter.fullPath + relativePath
}

// Initialize the multiplexer
Expand Down Expand Up @@ -221,7 +223,7 @@ func (r *Router) HandleFunc(
r.mux.HandleFunc(pattern, firstHandler.ServeHTTP)

if r.logger != nil && r.mode != nil && !r.mode.IsProd() {
r.logger.RegisterRoute(r.relativePath, pattern)
r.logger.RegisterRoute(r.fullPath, pattern)
}
}

Expand Down Expand Up @@ -249,7 +251,7 @@ func (r *Router) ExactHandleFunc(
r.mux.HandleFunc(method+" "+path, firstHandler.ServeHTTP)

if r.logger != nil && r.mode != nil && !r.mode.IsProd() {
r.logger.RegisterRoute(r.relativePath, pattern)
r.logger.RegisterRoute(r.fullPath, pattern)
}
}

Expand Down

0 comments on commit f1af465

Please sign in to comment.