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
|
@ -46,6 +46,12 @@ func (m *Muxer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||
http.NotFoundHandler().ServeHTTP(rw, req)
|
||||
}
|
||||
|
||||
// GetRulePriority computes the priority for a given rule.
|
||||
// The priority is calculated using the length of rule.
|
||||
func GetRulePriority(rule string) int {
|
||||
return len(rule)
|
||||
}
|
||||
|
||||
// AddRoute add a new route to the router.
|
||||
func (m *Muxer) AddRoute(rule string, priority int, handler http.Handler) error {
|
||||
parse, err := m.parser.Parse(rule)
|
||||
|
@ -64,10 +70,6 @@ func (m *Muxer) AddRoute(rule string, priority int, handler http.Handler) error
|
|||
return fmt.Errorf("error while adding rule %s: %w", rule, err)
|
||||
}
|
||||
|
||||
if priority == 0 {
|
||||
priority = len(rule)
|
||||
}
|
||||
|
||||
m.routes = append(m.routes, &route{
|
||||
handler: handler,
|
||||
matchers: matchers,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue