Refactor to support multiple server instances in shared library

This commit is contained in:
Pijus Kamandulis
2024-12-18 19:39:57 +02:00
parent 84c33e3c8e
commit 777034181f
34 changed files with 503 additions and 369 deletions

View File

@@ -7,10 +7,10 @@ import (
"github.com/pikami/cosmium/api/config"
)
func StripTrailingSlashes(r *gin.Engine) gin.HandlerFunc {
func StripTrailingSlashes(r *gin.Engine, config config.ServerConfig) gin.HandlerFunc {
return func(c *gin.Context) {
path := c.Request.URL.Path
if len(path) > 1 && path[len(path)-1] == '/' && !strings.Contains(path, config.Config.ExplorerBaseUrlLocation) {
if len(path) > 1 && path[len(path)-1] == '/' && !strings.Contains(path, config.ExplorerBaseUrlLocation) {
c.Request.URL.Path = path[:len(path)-1]
r.HandleContext(c)
c.Abort()