Improve error on router without service.

Co-authored-by: Mathieu Lonjaret <mathieu.lonjaret@gmail.com>
This commit is contained in:
Ludovic Fernandez 2019-07-19 16:42:04 +02:00 committed by Traefiker Bot
parent c39a550b00
commit 1800b0b69c
13 changed files with 125 additions and 40 deletions

View file

@ -100,15 +100,19 @@ func getHTTPServiceSection(services map[string]*runtime.ServiceInfo) *section {
func getHTTPMiddlewareSection(middlewares map[string]*runtime.MiddlewareInfo) *section {
var countErrors int
for _, md := range middlewares {
if md.Err != nil {
var countWarnings int
for _, mid := range middlewares {
switch mid.Status {
case runtime.StatusDisabled:
countErrors++
case runtime.StatusWarning:
countWarnings++
}
}
return &section{
Total: len(middlewares),
Warnings: 0,
Warnings: countWarnings,
Errors: countErrors,
}
}

View file

@ -85,6 +85,7 @@ func TestHandler_Overview(t *testing.T) {
Users: []string{"admin:admin"},
},
},
Status: runtime.StatusEnabled,
},
"addPrefixTest@myprovider": {
Middleware: &dynamic.Middleware{
@ -99,7 +100,8 @@ func TestHandler_Overview(t *testing.T) {
Prefix: "/toto",
},
},
Err: []string{"error"},
Err: []string{"error"},
Status: runtime.StatusDisabled,
},
},
Routers: map[string]*runtime.RouterInfo{

View file

@ -30,6 +30,7 @@
"addPrefix": {
"prefix": "/toto"
},
"status": "enabled",
"usedBy": [
"bar@myprovider"
]
@ -38,6 +39,7 @@
"addPrefix": {
"prefix": "/titi"
},
"status": "enabled",
"usedBy": [
"test@myprovider"
]
@ -48,6 +50,7 @@
"admin:admin"
]
},
"status": "enabled",
"usedBy": [
"bar@myprovider",
"test@myprovider"

View file

@ -6,6 +6,7 @@
},
"name": "auth@myprovider",
"provider": "myprovider",
"status": "enabled",
"usedBy": [
"bar@myprovider",
"test@myprovider"

View file

@ -5,6 +5,7 @@
},
"name": "addPrefixTest@myprovider",
"provider": "myprovider",
"status": "enabled",
"usedBy": [
"test@myprovider"
]

View file

@ -5,6 +5,7 @@
},
"name": "addPrefixTest@anotherprovider",
"provider": "anotherprovider",
"status": "enabled",
"usedBy": [
"bar@myprovider"
]
@ -15,6 +16,7 @@
},
"name": "addPrefixTest@myprovider",
"provider": "myprovider",
"status": "enabled",
"usedBy": [
"test@myprovider"
]
@ -27,6 +29,7 @@
},
"name": "auth@myprovider",
"provider": "myprovider",
"status": "enabled",
"usedBy": [
"bar@myprovider",
"test@myprovider"