Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add headers for text match? #101

Open
mercul3s opened this issue Nov 8, 2016 · 0 comments
Open

Add headers for text match? #101

mercul3s opened this issue Nov 8, 2016 · 0 comments

Comments

@mercul3s
Copy link

mercul3s commented Nov 8, 2016

I'm trying to use Github's metadata matching to return code snippets/highlights in the response, as documented in https://developer.github.com/v3/search/#text-match-metadata. I know that I can add my own headers in HTTPoison, ie

header_list = Enum.to_list(headers)
    [{"Accept", "application/vnd.github.v3.text-match+json"} | header_list]

So I can get back something like this:

...
  "object_type": "FileContent",
  "property": "content",
  "fragment": "\",\n            \"key_limit\": 2,\n            \"owner\": {\n                \"email",
  "matches": [
    {
      "text": "key_limit",
      "indices": [
        16,
        25
      ]
	}
...

Is there a way to pass the header info during the client creation? I tried something like the following, but no luck:

Tentacat.Client.new(%{access_token: "#{token}", accept: "application/vnd.github.v3.text-match+json"}, "#{@uri}")

I also tried wrapping HTTPoison.base to pass the accept header, but I'm assuming that'll only work if I'm using all the HTTPoison base methods directly. Attempts to add text match as a header return results as a regular search api call. Any suggestions?

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

No branches or pull requests

1 participant