mirror of
https://github.com/pikami/cosmium.git
synced 2026-11-01 05:55:36 +00:00
serve request paths with trailing slashes, as sent by python client
This commit is contained in:
1 parent
20af73ee9c
commit
9abef691d6
3 files changed
+76
-7
No files matched your search
@@ -0,0 +1,17 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func TrailingSlashStripper() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if (len(c.Request.URL.Path)) > 1 { //dont strip root dir slash, path="/"
|
||||
var stripped_path = strings.TrimSuffix(c.Request.URL.Path, "/")
|
||||
c.Request.URL.Path = stripped_path
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user