Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path conflict issue #4123

Open
sreejithag opened this issue Dec 26, 2024 · 0 comments
Open

Path conflict issue #4123

sreejithag opened this issue Dec 26, 2024 · 0 comments

Comments

@sreejithag
Copy link

sreejithag commented Dec 26, 2024

Description

I need two paths in one of my project

/:token
/:customPath/:token

i understand the issues with the http router
is their any any workaround to fix this issue other than adding a wild card pattern and match with interceptor

How to reproduce

package main

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

func main() {
	r := gin.Default()

	r.GET("/:custom/:token", func(c *gin.Context) {
		custom := c.Param("custom")
		token := c.Param("token")
		c.JSON(200, gin.H{
			"message": "Specific route",
			"custom":  custom,
			"token":   token,
		})
	})

	r.GET("/:token", func(c *gin.Context) {
		token := c.Param("token")
		c.JSON(200, gin.H{
			"message": "General route",
			"token":   token,
		})
	})

	r.Run(":8080") // Start the server on port 8080
}

Expectations

panic: ':token' in new path '/:token' conflicts with existing wildcard ':custom' in existing prefix '/:custom'

Environment

  • go version: 1.23.4
  • gin version (or commit ref): 1.10.0
  • operating system: macOS 15.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant