Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #22 from PagerDuty/COL-1351-extend-client-for-user…
Browse files Browse the repository at this point in the history
…-token

[COL-1351] ability to add additional headers to client with user token
  • Loading branch information
esurat20 authored May 25, 2021
2 parents 8646208 + 07a0cb5 commit 7d160fb
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/mixduty/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@ defmodule Mixduty.Client do
Mixduty.Client.new("myauthtoken")
"""
def new(auth) do
new(auth, headers: [])
end

@doc """
Create the client with additional headers
#### Example
Mixduty.Client.new("myauthtoken", [headers: [{"X-EARLY-ACCESS", "business-impact-early-access"}])
"""
def new(auth, headers: additional_headers) do
%Client{
headers: [
{"Accept", "application/vnd.pagerduty+json;version=2"},
{"Authorization", "Token token=#{auth}"},
{"Content-type", "application/json"}
]
headers:
[
{"Accept", "application/vnd.pagerduty+json;version=2"},
{"Authorization", "Token token=#{auth}"},
{"Content-type", "application/json"}
] ++ additional_headers
}
end

Expand Down

0 comments on commit 7d160fb

Please sign in to comment.