disambiguate routing
This commit is contained in:
parent
afb2376286
commit
e2af935b83
2 changed files with 8 additions and 8 deletions
|
@ -131,7 +131,7 @@ func TestPrivateAnnounce(t *testing.T) {
|
|||
cfg := config.DefaultConfig
|
||||
cfg.Private = true
|
||||
|
||||
url := "/yby47f04riwpndba456rqxtmifenqxx2/announce?info_hash=%89%d4%bcR%11%16%ca%1dB%a2%f3%0d%1f%27M%94%e4h%1d%af&peer_id=-TR2820-l71jtqkl898b&port=51413&uploaded=0&downloaded=0&left=0&numwant=1&key=3c8e3319&compact=0"
|
||||
url := "/users/yby47f04riwpndba456rqxtmifenqxx2/announce?info_hash=%89%d4%bcR%11%16%ca%1dB%a2%f3%0d%1f%27M%94%e4h%1d%af&peer_id=-TR2820-l71jtqkl898b&port=51413&uploaded=0&downloaded=0&left=0&numwant=1&key=3c8e3319&compact=0"
|
||||
golden1 := "d8:completei1e10:incompletei2e8:intervali1800e12:min intervali900e5:peersld2:ip9:127.0.0.17:peer id20:-TR2820-l71jtqkl8xx14:porti34000eeee"
|
||||
golden2 := "d8:completei1e10:incompletei2e8:intervali1800e12:min intervali900e5:peersld2:ip32:2001:0:53aa:64c:0:7f83:bc43:dec97:peer id20:-TR2820-l71jtqkl8xx34:porti34000eeee"
|
||||
got, err := testRoute(&cfg, url)
|
||||
|
@ -142,7 +142,7 @@ func TestPrivateAnnounce(t *testing.T) {
|
|||
t.Errorf("\ngot: %s\nwanted: %s\nwanted: %s", got, golden1, golden2)
|
||||
}
|
||||
|
||||
url = "/yby47f04riwpndba456rqxtmifenqxx2/announce?info_hash=%89%d4%bcR%11%16%ca%1dB%a2%f3%0d%1f%27M%94%e4h%1d%af&peer_id=-TR2820-l71jtqkl898b&port=51413&uploaded=0&downloaded=0&left=0&numwant=2&key=3c8e3319&compact=0"
|
||||
url = "/users/yby47f04riwpndba456rqxtmifenqxx2/announce?info_hash=%89%d4%bcR%11%16%ca%1dB%a2%f3%0d%1f%27M%94%e4h%1d%af&peer_id=-TR2820-l71jtqkl898b&port=51413&uploaded=0&downloaded=0&left=0&numwant=2&key=3c8e3319&compact=0"
|
||||
golden1 = "d8:completei1e10:incompletei2e8:intervali1800e12:min intervali900e5:peersld2:ip9:127.0.0.17:peer id20:-TR2820-l71jtqkl8xx14:porti34000eed2:ip32:2001:0:53aa:64c:0:7f83:bc43:dec97:peer id20:-TR2820-l71jtqkl8xx34:porti34000eeee"
|
||||
got, err = testRoute(&cfg, url)
|
||||
if err != nil {
|
||||
|
|
12
http/http.go
12
http/http.go
|
@ -64,13 +64,9 @@ func makeHandler(handler ResponseHandler) httprouter.Handle {
|
|||
func setupRoutes(t *Tracker, cfg *config.Config) *httprouter.Router {
|
||||
r := httprouter.New()
|
||||
|
||||
r.GET("/torrents/:infohash", makeHandler(t.getTorrent))
|
||||
r.PUT("/torrents/:infohash", makeHandler(t.putTorrent))
|
||||
r.DELETE("/torrents/:infohash", makeHandler(t.delTorrent))
|
||||
|
||||
if cfg.Private {
|
||||
r.GET("/:passkey/announce", makeHandler(t.ServeAnnounce))
|
||||
r.GET("/:passkey/scrape", makeHandler(t.ServeScrape))
|
||||
r.GET("/users/:passkey/announce", makeHandler(t.ServeAnnounce))
|
||||
r.GET("/users/:passkey/scrape", makeHandler(t.ServeScrape))
|
||||
|
||||
r.PUT("/users/:passkey", makeHandler(t.putUser))
|
||||
r.DELETE("/users/:passkey", makeHandler(t.delUser))
|
||||
|
@ -84,6 +80,10 @@ func setupRoutes(t *Tracker, cfg *config.Config) *httprouter.Router {
|
|||
r.DELETE("/clients/:clientID", makeHandler(t.delClient))
|
||||
}
|
||||
|
||||
r.GET("/torrents/:infohash", makeHandler(t.getTorrent))
|
||||
r.PUT("/torrents/:infohash", makeHandler(t.putTorrent))
|
||||
r.DELETE("/torrents/:infohash", makeHandler(t.delTorrent))
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue