summaryrefslogtreecommitdiffhomepage
path: root/api
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-25 16:08:09 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-25 16:08:09 -0800
commit0adb1d0dcd57b17444a3364e576b3bcf94266ce4 (patch)
tree6d3fa06b869eaebf4ad795a7a4f278337bd2c41e /api
parentdd0bd625475f07306b5176a9695d66a212249191 (diff)
rest: use []byte instead of interface{} for REST response
Some Marshall method is not thread-safe. They can't be called by a goroutine for a REST client. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'api')
-rw-r--r--api/rest.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/api/rest.go b/api/rest.go
index 91b98e57..a5fdfaa7 100644
--- a/api/rest.go
+++ b/api/rest.go
@@ -16,7 +16,6 @@
package api
import (
- "encoding/json"
log "github.com/Sirupsen/logrus"
"github.com/gorilla/mux"
"net/http"
@@ -67,7 +66,7 @@ func NewRestRequest(reqType int, remoteAddr string) *RestRequest {
type RestResponse struct {
ResponseErr error
- Data interface{}
+ Data []byte
}
func (r *RestResponse) Err() error {
@@ -148,8 +147,7 @@ func (rs *RestServer) neighbor(w http.ResponseWriter, r *http.Request, reqType i
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
- j, _ := json.Marshal(res.Data)
- w.Write(j)
+ w.Write(res.Data)
}
func (rs *RestServer) Neighbor(w http.ResponseWriter, r *http.Request) {
@@ -174,8 +172,7 @@ func (rs *RestServer) Neighbors(w http.ResponseWriter, r *http.Request) {
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
- j, _ := json.Marshal(res.Data)
- w.Write(j)
+ w.Write(res.Data)
}
func NotFoundHandler(w http.ResponseWriter, r *http.Request) {