Skip to content

Conversation

@antoineco
Copy link
Contributor

Thanks for this package! 🙌 We use it @triggermesh and have a use case for bubbling up the HTTP code returned by the HEC endpoint back to a message sender.

We tackled this by de-serializing the response body to a HEC response object (as documented at https://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTinput#services.2Fcollector; you need to click "expand" near the POST method), and returning it as the error.

If the caller is interested in reading the contents of that response object, they can simply assert the value of the error as follows:

if hecResp, ok := err.(*splunk.EventCollectorResponse); ok  {
    // do something with hecResp
}

Additionally, one can determine the HTTP status code associated with a particular HEC status code as follows:

httpCode, err := hecResp.StatusCode.HTTPCode()

@ZachtimusPrime
Copy link
Owner

Sorry it's been so long for me to look back at this project. It's awesome that a decent amount of individuals/companies are making use of this. Thank you for the errors contribution, I'm probably going to merge this with the go module and millisecond timestamp PRs and bump to semver 2.0.0.

@ZachtimusPrime ZachtimusPrime merged commit acf6f46 into ZachtimusPrime:master Oct 8, 2020
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.

2 participants