feat(integrations): changed response structure
This commit is contained in:
parent
0b51a40254
commit
2e227f6584
1 changed files with 22 additions and 12 deletions
|
|
@ -27,20 +27,30 @@ type elasticsearchLog struct {
|
|||
Message string
|
||||
Time time.Time `json:"utc_time"` // Should be parsed automatically from RFC3339
|
||||
}
|
||||
|
||||
type elasticResponce struct {
|
||||
Hits struct {
|
||||
//Total struct {
|
||||
// Value int
|
||||
//}
|
||||
Hits []struct {
|
||||
Id string `json:"_id"`
|
||||
Source json.RawMessage `json:"_source"`
|
||||
} `json:"hits"`
|
||||
} `json:"hits"`
|
||||
//map[string]interface{}
|
||||
// SearchResult represents the result of the search operation
|
||||
type elasticResponse struct {
|
||||
Hits ResultHits `json:"hits"`
|
||||
ScrollId string `json:"_scroll_id"`
|
||||
}
|
||||
|
||||
// ResultHits represents the result of the search hits
|
||||
type ResultHits struct {
|
||||
Hits []struct {
|
||||
Id string `json:"_id"`
|
||||
Source json.RawMessage `json:"_source"`
|
||||
} `json:"hits"`
|
||||
}
|
||||
//type elasticResponse struct {
|
||||
// Hits struct {
|
||||
// Hits []struct {
|
||||
// Id string `json:"_id"`
|
||||
// Source json.RawMessage `json:"_source"`
|
||||
// } `json:"hits"`
|
||||
// } `json:"hits"`
|
||||
// ScrollId string `json:"_scroll_id"`
|
||||
//}
|
||||
|
||||
func (es *elasticsearch) Request(c *client) error {
|
||||
address := es.Host + ":" + es.Port.String()
|
||||
apiKey := b64.StdEncoding.EncodeToString([]byte(es.ApiKeyId + ":" + es.ApiKey))
|
||||
|
|
@ -150,7 +160,7 @@ func (es *elasticsearch) Request(c *client) error {
|
|||
// log.Println(mapResp)
|
||||
//}
|
||||
|
||||
var esResp elasticResponce
|
||||
var esResp elasticResponse
|
||||
if err := json.NewDecoder(res.Body).Decode(&esResp); err != nil {
|
||||
log.Printf("Error parsing the response body: %s\n", err)
|
||||
return fmt.Errorf("Error parsing the response body: %s", err)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue