Skip to content

Adapt Kibana interface for external usage#12266

Merged
jalvz merged 2 commits intoelastic:masterfrom
jalvz:adapt-kibana-client
May 24, 2019
Merged

Adapt Kibana interface for external usage#12266
jalvz merged 2 commits intoelastic:masterfrom
jalvz:adapt-kibana-client

Conversation

@jalvz
Copy link
Copy Markdown
Contributor

@jalvz jalvz commented May 24, 2019

  • Adds Kibana kbn-xsrf header (security).
  • Implements RoundTrip interface: facilitates testing outside the package, where there is no access to conn.http
  • Breaks down SendRequest in 2 methods, so external callers not interested in the extractError functionality can get the bare *Response object.

@jalvz jalvz requested a review from a team as a code owner May 24, 2019 08:54

retError = extractError(result)
return resp.StatusCode, result, retError
func (conn *Connection) RoundTrip(r *http.Request) (*http.Response, error) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method Connection.RoundTrip should have comment or be unexported

return resp.StatusCode, result, retError
}

func (conn *Connection) Send(method, extraPath string,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method Connection.Send should have comment or be unexported

@jalvz jalvz requested a review from kvch May 24, 2019 08:56

resp, err := conn.Send(method, extraPath, params, headers, body)
if err != nil {
return 0, nil, fmt.Errorf("fail to execute the HTTP %s request: %v", method, err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use "%+v" instead of "%v".

Copy link
Copy Markdown
Contributor

@kvch kvch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one minor comment. Otherwise 👍


retError = extractError(result)
return resp.StatusCode, result, retError
// Implements RoundTrip interface
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment on exported method Connection.RoundTrip should be of the form "RoundTrip ..."

return resp.StatusCode, result, retError
}

// Sends an application/json request to Kibana with appropriate kbn headers
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment on exported method Connection.Send should be of the form "Send ..."

@jalvz
Copy link
Copy Markdown
Contributor Author

jalvz commented May 24, 2019

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants