diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-03-11 15:31:31 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-03-20 22:26:48 +0900 |
commit | 444d48662ea7b2f8dcd56a5590d7b820552ad21a (patch) | |
tree | 08bc445bd773c2a16e577db85279b5d582ad384f /api | |
parent | 9355715ea394cb232d933ca20e8365b126ae6302 (diff) |
api/cli: add show global command
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'api')
-rw-r--r-- | api/rest.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/api/rest.go b/api/rest.go index f2bdd42e..656b5583 100644 --- a/api/rest.go +++ b/api/rest.go @@ -38,10 +38,12 @@ const ( REQ_NEIGHBOR_SOFT_RESET_OUT REQ_NEIGHBOR_ENABLE REQ_NEIGHBOR_DISABLE + REQ_GLOBAL_RIB ) const ( BASE_VERSION = "/v1" + GLOBAL = "/bgp/global" NEIGHBOR = "/bgp/neighbor" NEIGHBORS = "/bgp/neighbors" @@ -110,6 +112,7 @@ func NewRestServer(port int, bgpServerCh chan *RestRequest) *RestServer { // get local-rib of each neighbor. // -- curl -i -X GET http://<ownIP>:8080/v1/bgp/neighbor/<remote address of target neighbor>/local-rib/<rf> func (rs *RestServer) Serve() { + global := BASE_VERSION + GLOBAL neighbor := BASE_VERSION + NEIGHBOR neighbors := BASE_VERSION + NEIGHBORS @@ -118,6 +121,7 @@ func (rs *RestServer) Serve() { showObjectURL := "/{" + PARAM_SHOW_OBJECT + "}" operationURL := "/{" + PARAM_OPERATION + "}" routeFamilyURL := "/{" + PARAM_ROUTE_FAMILY + "}" + r.HandleFunc(global+showObjectURL+routeFamilyURL, rs.GlobalGET).Methods("GET") r.HandleFunc(neighbors, rs.NeighborGET).Methods("GET") r.HandleFunc(neighbor+perPeerURL, rs.NeighborGET).Methods("GET") r.HandleFunc(neighbor+perPeerURL+showObjectURL+routeFamilyURL, rs.NeighborGET).Methods("GET") @@ -213,6 +217,19 @@ func (rs *RestServer) NeighborGET(w http.ResponseWriter, r *http.Request) { } } +func (rs *RestServer) GlobalGET(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + if showObject, ok := params[PARAM_SHOW_OBJECT]; ok { + switch showObject { + case "rib": + rs.neighbor(w, r, REQ_GLOBAL_RIB) + default: + NotFoundHandler(w, r) + } + } + +} + func NotFoundHandler(w http.ResponseWriter, r *http.Request) { http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) } |