mirror of
https://github.com/alice-lg/birdwatcher.git
synced 2025-03-09 00:00:05 +01:00
Fixed /symbols endpoint.
This commit is contained in:
parent
439ee0d5d0
commit
6e8734fa90
2 changed files with 15 additions and 3 deletions
|
@ -167,7 +167,12 @@ func parseSymbols(reader io.Reader) Parsed {
|
|||
|
||||
if regex.symbols.keyRx.MatchString(line) {
|
||||
groups := regex.symbols.keyRx.FindStringSubmatch(line)
|
||||
res[groups[2]] = groups[1]
|
||||
|
||||
if _, ok := res[groups[2]]; !ok {
|
||||
res[groups[2]] = []string{}
|
||||
}
|
||||
|
||||
res[groups[2]] = append(res[groups[2]].([]string), groups[1])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package endpoints
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"net/http"
|
||||
|
||||
"github.com/alice-lg/birdwatcher/bird"
|
||||
|
@ -13,10 +14,16 @@ func Symbols(r *http.Request, ps httprouter.Params) (bird.Parsed, bool) {
|
|||
|
||||
func SymbolTables(r *http.Request, ps httprouter.Params) (bird.Parsed, bool) {
|
||||
val, from_cache := bird.Symbols()
|
||||
return bird.Parsed{"symbols": val["routing table"]}, from_cache
|
||||
if reflect.DeepEqual(val, bird.NilParse) || reflect.DeepEqual(val, bird.BirdError) {
|
||||
return val, from_cache
|
||||
}
|
||||
return bird.Parsed{"symbols": val["symbols"].(bird.Parsed)["routing table"]}, from_cache
|
||||
}
|
||||
|
||||
func SymbolProtocols(r *http.Request, ps httprouter.Params) (bird.Parsed, bool) {
|
||||
val, from_cache := bird.Symbols()
|
||||
return bird.Parsed{"symbols": val["protocols"]}, from_cache
|
||||
if reflect.DeepEqual(val, bird.NilParse) || reflect.DeepEqual(val, bird.BirdError) {
|
||||
return val, from_cache
|
||||
}
|
||||
return bird.Parsed{"symbols": val["symbols"].(bird.Parsed)["protocol"]}, from_cache
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue