Added router priority to webui's list and detail page

This commit is contained in:
bendre90 2023-01-09 17:24:05 +01:00 committed by GitHub
parent cd90b9761a
commit 8cd4923e72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 2913 additions and 131 deletions

View file

@ -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 {