fix default docker dest to include container

This commit is contained in:
Umputun 2021-04-28 13:40:59 -05:00
parent b04832658e
commit 69bb10d42f
2 changed files with 9 additions and 9 deletions

View File

@ -70,7 +70,7 @@ func (d *Docker) List() ([]discovery.URLMapper, error) {
res := make([]discovery.URLMapper, 0, len(containers))
for _, c := range containers {
enabled, explicit := false, false
srcURL := "^/(.*)"
srcURL := fmt.Sprintf("^/%s/(.*)", c.Name)
if d.AutoAPI {
enabled = true
srcURL = fmt.Sprintf("^/api/%s/(.*)", c.Name)

View File

@ -59,15 +59,15 @@ func TestDocker_List(t *testing.T) {
assert.Equal(t, "example.com", res[0].Server)
assert.Equal(t, "http://127.0.0.2:12345/ping", res[0].PingURL)
assert.Equal(t, "^/a/(.*)", res[1].SrcMatch.String())
assert.Equal(t, "http://127.0.0.2:12348/a/$1", res[1].Dst)
assert.Equal(t, "http://127.0.0.2:12348/ping", res[1].PingURL)
assert.Equal(t, "example.com", res[1].Server)
assert.Equal(t, "^/c2/(.*)", res[1].SrcMatch.String())
assert.Equal(t, "http://127.0.0.3:12346/$1", res[1].Dst)
assert.Equal(t, "http://127.0.0.3:12346/ping", res[1].PingURL)
assert.Equal(t, "*", res[1].Server)
assert.Equal(t, "^/(.*)", res[2].SrcMatch.String())
assert.Equal(t, "http://127.0.0.3:12346/$1", res[2].Dst)
assert.Equal(t, "http://127.0.0.3:12346/ping", res[2].PingURL)
assert.Equal(t, "*", res[2].Server)
assert.Equal(t, "^/a/(.*)", res[2].SrcMatch.String())
assert.Equal(t, "http://127.0.0.2:12348/a/$1", res[2].Dst)
assert.Equal(t, "http://127.0.0.2:12348/ping", res[2].PingURL)
assert.Equal(t, "example.com", res[2].Server)
}
func TestDocker_ListWithAutoAPI(t *testing.T) {