Added router priority to webui's list and detail page
This commit is contained in:
parent
cd90b9761a
commit
8cd4923e72
43 changed files with 2913 additions and 131 deletions
|
@ -4,7 +4,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
@ -62,7 +61,8 @@ func newTCPMiddlewareRepresentation(name string, mi *runtime.TCPMiddlewareInfo)
|
|||
func (h Handler) getTCPRouters(rw http.ResponseWriter, request *http.Request) {
|
||||
results := make([]tcpRouterRepresentation, 0, len(h.runtimeConfiguration.TCPRouters))
|
||||
|
||||
criterion := newSearchCriterion(request.URL.Query())
|
||||
query := request.URL.Query()
|
||||
criterion := newSearchCriterion(query)
|
||||
|
||||
for name, rt := range h.runtimeConfiguration.TCPRouters {
|
||||
if keepTCPRouter(name, rt, criterion) {
|
||||
|
@ -70,9 +70,7 @@ func (h Handler) getTCPRouters(rw http.ResponseWriter, request *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
sort.Slice(results, func(i, j int) bool {
|
||||
return results[i].Name < results[j].Name
|
||||
})
|
||||
sortRouters(query, results)
|
||||
|
||||
rw.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
@ -114,7 +112,8 @@ func (h Handler) getTCPRouter(rw http.ResponseWriter, request *http.Request) {
|
|||
func (h Handler) getTCPServices(rw http.ResponseWriter, request *http.Request) {
|
||||
results := make([]tcpServiceRepresentation, 0, len(h.runtimeConfiguration.TCPServices))
|
||||
|
||||
criterion := newSearchCriterion(request.URL.Query())
|
||||
query := request.URL.Query()
|
||||
criterion := newSearchCriterion(query)
|
||||
|
||||
for name, si := range h.runtimeConfiguration.TCPServices {
|
||||
if keepTCPService(name, si, criterion) {
|
||||
|
@ -122,9 +121,7 @@ func (h Handler) getTCPServices(rw http.ResponseWriter, request *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
sort.Slice(results, func(i, j int) bool {
|
||||
return results[i].Name < results[j].Name
|
||||
})
|
||||
sortServices(query, results)
|
||||
|
||||
rw.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
@ -166,7 +163,8 @@ func (h Handler) getTCPService(rw http.ResponseWriter, request *http.Request) {
|
|||
func (h Handler) getTCPMiddlewares(rw http.ResponseWriter, request *http.Request) {
|
||||
results := make([]tcpMiddlewareRepresentation, 0, len(h.runtimeConfiguration.Middlewares))
|
||||
|
||||
criterion := newSearchCriterion(request.URL.Query())
|
||||
query := request.URL.Query()
|
||||
criterion := newSearchCriterion(query)
|
||||
|
||||
for name, mi := range h.runtimeConfiguration.TCPMiddlewares {
|
||||
if keepTCPMiddleware(name, mi, criterion) {
|
||||
|
@ -174,9 +172,7 @@ func (h Handler) getTCPMiddlewares(rw http.ResponseWriter, request *http.Request
|
|||
}
|
||||
}
|
||||
|
||||
sort.Slice(results, func(i, j int) bool {
|
||||
return results[i].Name < results[j].Name
|
||||
})
|
||||
sortMiddlewares(query, results)
|
||||
|
||||
rw.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
@ -220,7 +216,10 @@ func keepTCPRouter(name string, item *runtime.TCPRouterInfo, criterion *searchCr
|
|||
return true
|
||||
}
|
||||
|
||||
return criterion.withStatus(item.Status) && criterion.searchIn(item.Rule, name)
|
||||
return criterion.withStatus(item.Status) &&
|
||||
criterion.searchIn(item.Rule, name) &&
|
||||
criterion.filterService(item.Service) &&
|
||||
criterion.filterMiddleware(item.Middlewares)
|
||||
}
|
||||
|
||||
func keepTCPService(name string, item *runtime.TCPServiceInfo, criterion *searchCriterion) bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue