api event supports for GET url params (#956)

This commit is contained in:
Shu xian 2019-11-19 00:37:45 +08:00 committed by Asim Aslam
parent 168cc06827
commit 5744050943

View File

@ -2,6 +2,7 @@
package event package event
import ( import (
"encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -91,12 +92,17 @@ func (e *event) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
// set body // set body
b, err := ioutil.ReadAll(r.Body) if r.Method == "GET" {
if err != nil { bytes, _ := json.Marshal(r.URL.Query())
http.Error(w, err.Error(), 500) ev.Data = string(bytes)
return } else {
b, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
ev.Data = string(b)
} }
ev.Data = string(b)
// get client // get client
c := e.options.Service.Client() c := e.options.Service.Client()