From f29ed4a8aece3175514c22c40dda79af6e093af4 Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期三, 30 十月 2019 19:28:12 +0800
Subject: [PATCH] 修正事件推送

---
 insertdata/EsClient.go |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/insertdata/EsClient.go b/insertdata/EsClient.go
index 7a72deb..6ecd30a 100644
--- a/insertdata/EsClient.go
+++ b/insertdata/EsClient.go
@@ -7,6 +7,7 @@
 	"io"
 	"io/ioutil"
 	"net/http"
+	"basic.com/valib/logger.git"
 	"strconv"
 	"strings"
 	"time"
@@ -128,7 +129,7 @@
     }
 **/
 
-func EsReq(method string, url string, parama []byte) (err error) {
+func EsReq(method string, url string, parama []byte) (maps map[string]interface{},err error) {
     timeout := time.Duration(10 * time.Second) 
     client := http.Client{
         Timeout: timeout,
@@ -138,13 +139,13 @@
 
     if err != nil {
         fmt.Println("build request fail !")
-        return err 
+        return nil, err
     }
 
     resp, err := client.Do(request)
     if err != nil{
         fmt.Println("request error: ", err)
-        return err 
+        return nil,err
     }
 
     defer resp.Body.Close()
@@ -153,9 +154,13 @@
     if err != nil {
         fmt.Println(err) 
     }
-
+	decoder := make(map[string]interface{})
+	if err := json.Unmarshal([]byte(string(body)), &decoder); err != nil {
+		return nil, err
+	}
     fmt.Println(string(body))
-    return nil 
+    logger.Info(string(body))
+    return decoder ,nil
 }
 
 

--
Gitblit v1.8.0