Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion libbeat/kibana/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package kibana

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
Expand Down Expand Up @@ -181,9 +182,16 @@ func (conn *Connection) Request(method, extraPath string,
func (conn *Connection) Send(method, extraPath string,
params url.Values, headers http.Header, body io.Reader) (*http.Response, error) {

return conn.SendWithContext(context.Background(), method, extraPath, params, headers, body)
}

// SendWithContext sends an application/json request to Kibana with appropriate kbn headers and the given context.
func (conn *Connection) SendWithContext(ctx context.Context, method, extraPath string,
params url.Values, headers http.Header, body io.Reader) (*http.Response, error) {

reqURL := addToURL(conn.URL, extraPath, params)

req, err := http.NewRequest(method, reqURL, body)
req, err := http.NewRequestWithContext(ctx, method, reqURL, body)
if err != nil {
return nil, fmt.Errorf("fail to create the HTTP %s request: %+v", method, err)
}
Expand Down