Skip to content

Commit

Permalink
fix(Base): set a proper user-agent as per api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceEEC committed May 22, 2018
1 parent 5507e76 commit 01010bc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rest/base.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ defmodule Crux.Rest.Base do

# Compile time constant so we can use it in guards
@api_base Endpoints.api()
# See: https://discordapp.com/developers/docs/reference#user-agent
@user_agent "DiscordBot (#{Crux.Rest.MixProject.project()[:source_url]}, v#{Crux.Rest.MixProject.project()[:version]}"

def process_request_body(""), do: ""
def process_request_body({:multipart, _} = body), do: body
Expand All @@ -19,7 +21,7 @@ defmodule Crux.Rest.Base do
|> Keyword.put_new_lazy(:authorization, fn ->
"Bot #{Application.fetch_env!(:crux_rest, :token)}"
end)
|> Keyword.put_new(:"user-agent", "Crux")
|> Keyword.put_new(:"user-agent", @user_agent)
end

defp handle_response({:ok, %HTTPoison.Response{status_code: 204}}, _method), do: :ok
Expand Down

0 comments on commit 01010bc

Please sign in to comment.