package middlewares

import (
	"github.com/gin-gonic/gin"
)

// ServePathStartFromAny is a middleware that
// serves the request without the base path before "any"
func ServePathStartFromAny(ctx *gin.Context) {
	originalPath := ctx.Request.URL.RawPath
	truePath := ctx.Param("any")
	if truePath == "" {
		ctx.Next()
		return
	}

	ctx.Request.URL.Path = truePath
	ctx.Next()
	ctx.Request.URL.Path = originalPath
}
