mirror of
https://github.com/alice-lg/birdwatcher.git
synced 2025-03-09 00:00:05 +01:00
Fixed /routes/count/protocol Endpoint which was returning no data,
because the wrong parser was called.
This commit is contained in:
parent
6e8734fa90
commit
08c63fc3a3
2 changed files with 6 additions and 7 deletions
|
@ -28,7 +28,7 @@ var Cache = struct {
|
|||
var NilParse Parsed = (Parsed)(nil)
|
||||
var BirdError Parsed = Parsed{"error": "bird unreachable"}
|
||||
|
||||
func isSpecial(ret Parsed) bool {
|
||||
func IsSpecial(ret Parsed) bool {
|
||||
return reflect.DeepEqual(ret, NilParse) || reflect.DeepEqual(ret, BirdError)
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ func RunAndParse(cmd string, parser func(io.Reader) Parsed) (Parsed, bool) {
|
|||
|
||||
func Status() (Parsed, bool) {
|
||||
birdStatus, from_cache := RunAndParse("status", parseStatus)
|
||||
if isSpecial(birdStatus) {
|
||||
if IsSpecial(birdStatus) {
|
||||
return birdStatus, from_cache
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ func Protocols() (Parsed, bool) {
|
|||
|
||||
func ProtocolsBgp() (Parsed, bool) {
|
||||
protocols, from_cache := Protocols()
|
||||
if isSpecial(protocols) {
|
||||
if IsSpecial(protocols) {
|
||||
return protocols, from_cache
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ func RoutesProto(protocol string) (Parsed, bool) {
|
|||
|
||||
func RoutesProtoCount(protocol string) (Parsed, bool) {
|
||||
cmd := routeQueryForChannel("route protocol "+protocol) + " count"
|
||||
return RunAndParse(cmd, parseRoutes)
|
||||
return RunAndParse(cmd, parseRoutesCount)
|
||||
}
|
||||
|
||||
func RoutesFiltered(protocol string) (Parsed, bool) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package endpoints
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"net/http"
|
||||
|
||||
"github.com/alice-lg/birdwatcher/bird"
|
||||
|
@ -14,7 +13,7 @@ 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()
|
||||
if reflect.DeepEqual(val, bird.NilParse) || reflect.DeepEqual(val, bird.BirdError) {
|
||||
if bird.IsSpecial(val) {
|
||||
return val, from_cache
|
||||
}
|
||||
return bird.Parsed{"symbols": val["symbols"].(bird.Parsed)["routing table"]}, from_cache
|
||||
|
@ -22,7 +21,7 @@ func SymbolTables(r *http.Request, ps httprouter.Params) (bird.Parsed, bool) {
|
|||
|
||||
func SymbolProtocols(r *http.Request, ps httprouter.Params) (bird.Parsed, bool) {
|
||||
val, from_cache := bird.Symbols()
|
||||
if reflect.DeepEqual(val, bird.NilParse) || reflect.DeepEqual(val, bird.BirdError) {
|
||||
if bird.IsSpecial(val) {
|
||||
return val, from_cache
|
||||
}
|
||||
return bird.Parsed{"symbols": val["symbols"].(bird.Parsed)["protocol"]}, from_cache
|
||||
|
|
Loading…
Add table
Reference in a new issue