Optimize code

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
Jianhui Zhao
2019-04-18 21:45:27 +08:00
parent 5efc781401
commit 395444f7d3
2 changed files with 3 additions and 7 deletions
+2 -4
View File
@@ -68,8 +68,7 @@ func handleCmdResp(data []byte) {
}
func cmdErrReply(err int, w http.ResponseWriter) {
msg := fmt.Sprintf(`{"err": %d, "msg":"%s"}`, err, cmdErrMsg[err])
w.Write([]byte(msg))
fmt.Fprintf(w, `{"err": %d, "msg":"%s"}`, err, cmdErrMsg[err])
}
func serveCmd(br *Broker, w http.ResponseWriter, r *http.Request) {
@@ -127,6 +126,5 @@ func serveCmd(br *Broker, w http.ResponseWriter, r *http.Request) {
msg := fmt.Sprintf(`{"type":"cmd","token":"%s","attrs":%s}`, token, string(body))
dev.wsWrite(websocket.TextMessage, []byte(msg))
resp := fmt.Sprintf(`{"token":"%s"}`, token)
w.Write([]byte(resp))
fmt.Fprintf(w, `{"token":"%s"}`, token)
}