Closed insanedefaults closed 6 years ago
As I said in #4, I'm all for any changes if if it benefits to the project ! From what I've read the alternative to HTTPotion are HTTPoison and Hickey as you said but also Tesla, tbh I don't know which one is the "best" and the more appropriate to our problem.
I'll start looking at this tonight and we'll see to change it as soon as possible !
In response to the conversation in #4 and here, I would throw my vote in just for HTTPoison over Tesla. It really doesn't have anything to do with Tesla being lacking at all though.
HTTPoison:
Tesla:
I would argue that Tesla may actually be more in line with "what Elixir code should be", but our requirements are not extensive. We are just looking for some quality of life improvements. HTTPoison is well supported, well spec'd, and widely used and tested.
Let's go for HTTPoison then !
Tried a bit on my side, replaced HTTPotion with HTTPoison and it seems to works perfectly. I don't have tried the async requests or streams, just a basic one like the one with HTTPotion.
def get_main(endpoint, opts \\ []) do
# Before, with HTTPotion
#HTTPotion.get("https://api.arknode.net/#{endpoint}" <> query(opts),
# headers: get_main_headers())
#|> Map.get(:body)
#|> Poison.Parser.parse!
# Now, with HTTPoison
response = HTTPoison.get!("https://api.arknode.net/#{endpoint}" <> query(opts), get_main_headers())
Poison.decode!(response.body)
end
It's very basic but still it works like before.
Looks good I'll close this out
Both have extremely similar APIs and it should be a fairly easy replacement. Switching would generally be a small quality of life change.
Additionally, both libraries have the capability to have functions extended so that using them seems more native to the Ark_Elixir implementation. This would require a decent shift so I think it's maybe not the time to talk about it- just an idea for the future.