Skip to content

Bug with mixed static and dynamic params #2894

@ibraheemdev

Description

@ibraheemdev

Cross posted from #2767

package main

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

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

	r.GET("/aa/:customer", newHandler("/aa/:customer"))
	r.GET("/aa/:customer/files/:file", newHandler("/aa/:customer/files/:file"))

	r.Run()
}

func newHandler(t string) func(c *gin.Context) {
	return func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": t,
		})
	}
}

For the above code example, the request results are:

/aa/1/files/aa  =>  /aa/:customer/files/:file
/aa/1/files/    =>  /aa/:customer
/aa/1/files     =>  404
/aa/1           =>  /aa/:customer

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions