Allow file provider to load config from files in a directory.
This commit is contained in:
parent
73e10c96cc
commit
4128c1ac8d
8 changed files with 442 additions and 45 deletions
|
@ -26,7 +26,7 @@ func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
|||
defer cmd.Process.Kill()
|
||||
|
||||
// Expected a 404 as we did not configure anything
|
||||
try.GetRequest("http://127.0.0.1:8000/", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound))
|
||||
err = try.GetRequest("http://127.0.0.1:8000/", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound))
|
||||
c.Assert(err, checker.IsNil)
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,22 @@ func (s *FileSuite) TestSimpleConfigurationNoPanic(c *check.C) {
|
|||
defer cmd.Process.Kill()
|
||||
|
||||
// Expected a 404 as we did not configure anything
|
||||
try.GetRequest("http://127.0.0.1:8000/", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound))
|
||||
err = try.GetRequest("http://127.0.0.1:8000/", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound))
|
||||
c.Assert(err, checker.IsNil)
|
||||
}
|
||||
|
||||
func (s *FileSuite) TestDirectoryConfiguration(c *check.C) {
|
||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/file/directory.toml")
|
||||
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
// Expected a 404 as we did not configure anything at /test
|
||||
err = try.GetRequest("http://127.0.0.1:8000/test", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
// Expected a 502 as there is no backend server
|
||||
err = try.GetRequest("http://127.0.0.1:8000/test2", 1000*time.Millisecond, try.StatusCodeIs(http.StatusBadGateway))
|
||||
c.Assert(err, checker.IsNil)
|
||||
}
|
||||
|
|
11
integration/fixtures/file/dir/simple1.toml
Normal file
11
integration/fixtures/file/dir/simple1.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
# rules
|
||||
[backends]
|
||||
[backends.backend1]
|
||||
[backends.backend1.servers.server1]
|
||||
url = "http://172.17.0.2:80"
|
||||
|
||||
[frontends]
|
||||
[frontends.frontend1]
|
||||
backend = "backend1"
|
||||
[frontends.frontend1.routes.test_1]
|
||||
rule = "Path:/test1"
|
11
integration/fixtures/file/dir/simple2.toml
Normal file
11
integration/fixtures/file/dir/simple2.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
# rules
|
||||
[backends]
|
||||
[backends.backend2]
|
||||
[backends.backend2.servers.server1]
|
||||
url = "http://172.17.0.2:80"
|
||||
|
||||
[frontends]
|
||||
[frontends.frontend2]
|
||||
backend = "backend2"
|
||||
[frontends.frontend2.routes.test_2]
|
||||
rule = "Path:/test2"
|
10
integration/fixtures/file/directory.toml
Normal file
10
integration/fixtures/file/directory.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
defaultEntryPoints = ["http"]
|
||||
|
||||
logLevel = "DEBUG"
|
||||
|
||||
[entryPoints]
|
||||
[entryPoints.http]
|
||||
address = ":8000"
|
||||
|
||||
[file]
|
||||
directory = "fixtures/file/dir/"
|
Loading…
Add table
Add a link
Reference in a new issue