Skip to content

Instantly share code, notes, and snippets.

@edgurgel
Created October 10, 2014 22:39
Show Gist options
  • Save edgurgel/5e8e9e412a03fb933cf1 to your computer and use it in GitHub Desktop.
Save edgurgel/5e8e9e412a03fb933cf1 to your computer and use it in GitHub Desktop.
Overriding HTTPoison.Base.request/5
defmodule Example do
use HTTPoison.Base
def request(method, url, body \\ "", headers \\ [], options \\ []) do
IO.inspect [method, url, body, headers, options]
super(method, url, body, headers, options)
end
end
@edgurgel
Copy link
Author

iex> Example.get("http://httparrot.herokuapp.com/get")
[:get, "http://httparrot.herokuapp.com/get", "", [], []]
%HTTPoison.Response{body: "{\n  \"args\": {},\n  \"headers\": {\n    \"host\": \"httparrot.herokuapp.com\",\n    \"connection\": \"close\",\n    \"user-agent\": \"hackney/0.14.1\",\n    \"x-request-id\": \"798c6728-e8b3-4b1a-8ee3-ad53f99f7dd3\",\n    \"x-forwarded-for\": \"103.21.172.205\",\n    \"x-forwarded-proto\": \"http\",\n    \"x-forwarded-port\": \"80\",\n    \"via\": \"1.1 vegur\",\n    \"connect-time\": \"2\",\n    \"x-request-start\": \"1412980751010\",\n    \"total-route-time\": \"0\"\n  },\n  \"url\": \"http://httparrot.herokuapp.com/get\",\n  \"origin\": \"10.165.27.245\"\n}",
 headers: %{"Connection" => "keep-alive", "Content-Length" => "495",
   "Content-Type" => "application/json",
   "Date" => "Fri, 10 Oct 2014 22:39:10 GMT", "Server" => "Cowboy",
   "Via" => "1.1 vegur"}, status_code: 200}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment