diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-25 06:09:06 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-25 06:09:06 -0800 |
commit | 3234ade75edd5c4b01f817cc127a13feb9c25c7b (patch) | |
tree | 99653f09b515c2f52f64f8ea5d95ce6835974a2c /api | |
parent | d9d527a65dd068e0a093ed94ad5effc13567a5e1 (diff) |
rest: use interface{} for REST response
Then rest.go can use an appropriate format. Likelly we support only
JSON though.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'api')
-rw-r--r-- | api/rest.go | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/api/rest.go b/api/rest.go index 909fd541..fc421805 100644 --- a/api/rest.go +++ b/api/rest.go @@ -80,7 +80,7 @@ type RestResponse interface { type RestResponseDefault struct { ResponseErr error - Data []byte + Data interface{} } func (r *RestResponseDefault) Err() error { @@ -96,14 +96,6 @@ type RestResponseNeighbor struct { UpdateCount int } -// Response struct for Rib -type RestResponseRib struct { - RestResponseDefault - RemoteAddr string - RemoteAs uint32 - RibInfo []string -} - type RestServer struct { port int bgpServerCh chan *RestRequest @@ -226,7 +218,8 @@ func (rs *RestServer) NeighborLocalRib(w http.ResponseWriter, r *http.Request) { res := resInf.(*RestResponseDefault) w.Header().Set("Content-Type", "application/json; charset=utf-8") - w.Write(res.Data) + j, _ := json.Marshal(res.Data) + w.Write(j) } func NotFoundHandler(w http.ResponseWriter, r *http.Request) { |