mirror of
https://github.com/umputun/reproxy.git
synced 2024-09-11 08:55:25 +03:00
don't resort rules for file provider inside the server #37
This commit is contained in:
parent
212129faf1
commit
8dca98c6b3
@ -110,10 +110,7 @@ func (d *File) List() (res []discovery.URLMapper, err error) {
|
||||
}
|
||||
}
|
||||
sort.Slice(res, func(i, j int) bool {
|
||||
if res[i].Server == res[j].Server {
|
||||
return res[i].SrcMatch.String() < res[j].SrcMatch.String()
|
||||
}
|
||||
return res[i].Server < res[j].Server
|
||||
return len(res[i].Server) > len(res[j].Server)
|
||||
})
|
||||
|
||||
err = fh.Close()
|
||||
|
@ -107,23 +107,24 @@ func TestFile_List(t *testing.T) {
|
||||
t.Logf("%+v", res)
|
||||
assert.Equal(t, 4, len(res))
|
||||
|
||||
assert.Equal(t, "/api/svc3/xyz", res[0].SrcMatch.String())
|
||||
assert.Equal(t, "http://127.0.0.3:8080/blah3/xyz", res[0].Dst)
|
||||
assert.Equal(t, "http://127.0.0.3:8080/ping", res[0].PingURL)
|
||||
assert.Equal(t, "*", res[0].Server)
|
||||
assert.Equal(t, "^/api/svc2/(.*)", res[0].SrcMatch.String())
|
||||
assert.Equal(t, "http://127.0.0.2:8080/blah2/$1/abc", res[0].Dst)
|
||||
assert.Equal(t, "", res[0].PingURL)
|
||||
assert.Equal(t, "srv.example.com", res[0].Server)
|
||||
|
||||
assert.Equal(t, "/web/", res[1].SrcMatch.String())
|
||||
assert.Equal(t, "/var/web", res[1].Dst)
|
||||
assert.Equal(t, "^/api/svc1/(.*)", res[1].SrcMatch.String())
|
||||
assert.Equal(t, "http://127.0.0.1:8080/blah1/$1", res[1].Dst)
|
||||
assert.Equal(t, "", res[1].PingURL)
|
||||
assert.Equal(t, "*", res[1].Server)
|
||||
|
||||
assert.Equal(t, "^/api/svc1/(.*)", res[2].SrcMatch.String())
|
||||
assert.Equal(t, "http://127.0.0.1:8080/blah1/$1", res[2].Dst)
|
||||
assert.Equal(t, "", res[2].PingURL)
|
||||
assert.Equal(t, "/api/svc3/xyz", res[2].SrcMatch.String())
|
||||
assert.Equal(t, "http://127.0.0.3:8080/blah3/xyz", res[2].Dst)
|
||||
assert.Equal(t, "http://127.0.0.3:8080/ping", res[2].PingURL)
|
||||
assert.Equal(t, "*", res[2].Server)
|
||||
|
||||
assert.Equal(t, "^/api/svc2/(.*)", res[3].SrcMatch.String())
|
||||
assert.Equal(t, "http://127.0.0.2:8080/blah2/$1/abc", res[3].Dst)
|
||||
assert.Equal(t, "/web/", res[3].SrcMatch.String())
|
||||
assert.Equal(t, "/var/web", res[3].Dst)
|
||||
assert.Equal(t, "", res[3].PingURL)
|
||||
assert.Equal(t, "srv.example.com", res[3].Server)
|
||||
assert.Equal(t, "*", res[3].Server)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user