1
0
Fork 0
mirror of https://github.com/alice-lg/birdwatcher.git synced 2025-03-09 00:00:05 +01:00

Implement new endpoint /routes/count/primary

This commit is contained in:
Patrick Seeburger 2018-09-28 16:44:08 +02:00 committed by Benedikt Rudolph
parent 541ea6d84d
commit 7fd2dfd0cf
4 changed files with 17 additions and 0 deletions

View file

@ -214,6 +214,11 @@ func RoutesProtoCount(protocol string) (Parsed, bool) {
return RunAndParse(cmd, parseRoutesCount)
}
func RoutesProtoPrimaryCount(protocol string) (Parsed, bool) {
cmd := routeQueryForChannel("route primary protocol "+protocol) + " count"
return RunAndParse(cmd, parseRoutesCount)
}
func RoutesFiltered(protocol string) (Parsed, bool) {
cmd := routeQueryForChannel("route all filtered protocol " + protocol)
return RunAndParse(cmd, parseRoutes)

View file

@ -65,6 +65,9 @@ func makeRouter(config endpoints.ServerConfig) *httprouter.Router {
if isModuleEnabled("routes_count_table", whitelist) {
r.GET("/routes/count/table/:table", endpoints.Endpoint(endpoints.TableCount))
}
if isModuleEnabled("routes_count_primary", whitelist) {
r.GET("/routes/count/primary/:protocol", endpoints.Endpoint(endpoints.ProtoPrimaryCount))
}
if isModuleEnabled("routes_filtered", whitelist) {
r.GET("/routes/filtered/:protocol", endpoints.Endpoint(endpoints.RoutesFiltered))
}

View file

@ -58,6 +58,14 @@ func ProtoCount(r *http.Request, ps httprouter.Params) (bird.Parsed, bool) {
return bird.RoutesProtoCount(protocol)
}
func ProtoPrimaryCount(r *http.Request, ps httprouter.Params) (bird.Parsed, bool) {
protocol, err := ValidateProtocolParam(ps.ByName("protocol"))
if err != nil {
return bird.Parsed{"error": fmt.Sprintf("%s", err)}, false
}
return bird.RoutesProtoPrimaryCount(protocol)
}
func TableCount(r *http.Request, ps httprouter.Params) (bird.Parsed, bool) {
return bird.RoutesTableCount(ps.ByName("table"))
}

View file

@ -18,6 +18,7 @@ allow_from = []
# routes_table
# routes_count_protocol
# routes_count_table
# routes_count_primary
# routes_filtered
# routes_prefixed
# routes_noexport