Skip to content

Commit

Permalink
add exported routes endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
nstgt committed Jan 26, 2020
1 parent a94742a commit e53ff72
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions birdwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func makeRouter(config endpoints.ServerConfig) *httprouter.Router {
if isModuleEnabled("routes_filtered", whitelist) {
r.GET("/routes/filtered/:protocol", endpoints.Endpoint(endpoints.RoutesFiltered))
}
if isModuleEnabled("routes_export", whitelist) {
r.GET("/routes/export/:protocol", endpoints.Endpoint(endpoints.RoutesExport))
}
if isModuleEnabled("routes_noexport", whitelist) {
r.GET("/routes/noexport/:protocol", endpoints.Endpoint(endpoints.RoutesNoExport))
}
Expand Down
9 changes: 9 additions & 0 deletions endpoints/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ func RoutesFiltered(r *http.Request, ps httprouter.Params, useCache bool) (bird.
return bird.RoutesFiltered(useCache, protocol)
}

func RoutesExport(r *http.Request, ps httprouter.Params, useCache bool) (bird.Parsed, bool) {
protocol, err := ValidateProtocolParam(ps.ByName("protocol"))
if err != nil {
return bird.Parsed{"error": fmt.Sprintf("%s", err)}, false
}

return bird.RoutesExport(useCache, protocol)
}

func RoutesNoExport(r *http.Request, ps httprouter.Params, useCache bool) (bird.Parsed, bool) {
protocol, err := ValidateProtocolParam(ps.ByName("protocol"))
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions etc/birdwatcher/birdwatcher.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ allow_uncached = false
# routes_count_primary
# routes_filtered
# routes_prefixed
# routes_export
# routes_noexport
# route_net
# routes_pipe_filtered_count
Expand All @@ -45,6 +46,7 @@ modules_enabled = ["status",
"routes_table_peer",
"routes_filtered",
"routes_prefixed",
"routes_export",
"routes_noexport",
"routes_pipe_filtered_count",
"routes_pipe_filtered"
Expand Down

0 comments on commit e53ff72

Please sign in to comment.