feat: use jiffy instead of poison
This commit is contained in:
parent
c351dcd5c4
commit
34474a01b6
|
@ -1,5 +1,7 @@
|
|||
defmodule Gh2ntfy.GhPoll do
|
||||
alias Gh2ntfy.LastPoll
|
||||
alias Gh2ntfy.Util
|
||||
|
||||
require Logger
|
||||
|
||||
use GenServer
|
||||
|
@ -33,7 +35,7 @@ defmodule Gh2ntfy.GhPoll do
|
|||
|
||||
case result do
|
||||
{:ok, %{body: body}} ->
|
||||
case Poison.decode(body) do
|
||||
case Util.catch_tuple(fn -> :jiffy.decode(body, [:return_maps]) end) do
|
||||
{:ok, res} ->
|
||||
Gh2ntfy.LastPoll.set_now()
|
||||
process_response(res)
|
||||
|
@ -81,7 +83,7 @@ defmodule Gh2ntfy.GhPoll do
|
|||
|
||||
defp get_issuecomment_url(api_url) do
|
||||
{:ok, %{body: body}} = Finch.build(:get, api_url) |> Finch.request(Gh2ntfy.Finch)
|
||||
%{"html_url" => url} = Poison.decode!(body)
|
||||
%{"html_url" => url} = :jiffy.decode(body, [:return_maps])
|
||||
url
|
||||
end
|
||||
end
|
||||
|
|
9
lib/gh2ntfy/util.ex
Normal file
9
lib/gh2ntfy/util.ex
Normal file
|
@ -0,0 +1,9 @@
|
|||
defmodule Gh2ntfy.Util do
|
||||
def catch_tuple(f) when is_function(f, 0) do
|
||||
try do
|
||||
{:ok, f.()}
|
||||
rescue
|
||||
e -> {:error, e}
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue