add exported routes endpoint

This commit is contained in:
Nasato Goto 2020-01-26 23:12:06 +09:00
parent a94742a23b
commit e53ff72205
3 changed files with 14 additions and 0 deletions

View File

@ -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))
}

View File

@ -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 {

View File

@ -27,6 +27,7 @@ allow_uncached = false
# routes_count_primary
# routes_filtered
# routes_prefixed
# routes_export
# routes_noexport
# route_net
# routes_pipe_filtered_count
@ -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"