Skip to content

Add headers for text match? #101

@mercul3s

Description

@mercul3s

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions