mux icon indicating copy to clipboard operation
mux copied to clipboard

segments after ":name" type will match wrong

Open mozhata opened this issue 7 years ago • 0 comments

there are two conflict router:

GET /v1/team/:tid/duty
GET /v1/team/:svc/info

the secode route will not match

package main

import (
	"log"
	"net/http"

	"github.com/beego/mux"
)

func main() {
	m := mux.New()
	m.Get("/v1/team/:tid/duty", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("hello, beego mux\n"))
	})
	m.Get("/v1/team/:svc/info", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("hello, beego mux 2\n"))
	})

	log.Fatal(http.ListenAndServe("127.0.0.1:2222", m))
}

curl:

mozhata@pc:try$ curl http://127.0.0.1:2222/v1/team/ididid/duty
hello, beego mux
mozhata@pc:try$ curl http://127.0.0.1:2222/v1/team/ididid/info
"/v1/team/ididid/info" not implemented

but replace :svc to :tid, these two routes all works

mozhata avatar Aug 02 '18 12:08 mozhata