add datadog deflate encoding
This commit is contained in:
parent
3700f7a10b
commit
904d09d91c
|
@ -2,6 +2,7 @@ package router
|
|||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"compress/zlib"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
@ -162,7 +163,9 @@ func datadogSeries(c *gin.Context) {
|
|||
var bs []byte
|
||||
var err error
|
||||
|
||||
if c.GetHeader("Content-Encoding") == "gzip" {
|
||||
enc := c.GetHeader("Content-Encoding")
|
||||
|
||||
if enc == "gzip" {
|
||||
r, err := gzip.NewReader(c.Request.Body)
|
||||
if err != nil {
|
||||
c.String(400, err.Error())
|
||||
|
@ -170,6 +173,14 @@ func datadogSeries(c *gin.Context) {
|
|||
}
|
||||
defer r.Close()
|
||||
bs, err = ioutil.ReadAll(r)
|
||||
} else if enc == "deflate" {
|
||||
r, err := zlib.NewReader(c.Request.Body)
|
||||
if err != nil {
|
||||
c.String(400, err.Error())
|
||||
return
|
||||
}
|
||||
defer r.Close()
|
||||
bs, err = ioutil.ReadAll(r)
|
||||
} else {
|
||||
defer c.Request.Body.Close()
|
||||
bs, err = ioutil.ReadAll(c.Request.Body)
|
||||
|
|
Loading…
Reference in New Issue