mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-11-22 08:01:00 +00:00
handle error with github network
This commit is contained in:
parent
712204ca17
commit
0c823a18ea
1 changed files with 10 additions and 12 deletions
|
@ -90,20 +90,18 @@ defmodule LiveBeats.Github do
|
||||||
defp secret, do: LiveBeats.config([:github, :client_secret])
|
defp secret, do: LiveBeats.config([:github, :client_secret])
|
||||||
|
|
||||||
defp http(host, method, path, query, headers, body \\ "") do
|
defp http(host, method, path, query, headers, body \\ "") do
|
||||||
{:ok, conn} = Mint.HTTP.connect(:https, host, 443)
|
|
||||||
|
|
||||||
path = path <> "?" <> URI.encode_query([{:client_id, client_id()} | query])
|
path = path <> "?" <> URI.encode_query([{:client_id, client_id()} | query])
|
||||||
|
|
||||||
{:ok, conn, ref} =
|
with {:ok, conn} <- Mint.HTTP.connect(:https, host, 443),
|
||||||
|
{:ok, conn, ref} <-
|
||||||
Mint.HTTP.request(
|
Mint.HTTP.request(
|
||||||
conn,
|
conn,
|
||||||
method,
|
method,
|
||||||
path,
|
path,
|
||||||
headers,
|
headers,
|
||||||
body
|
body
|
||||||
)
|
),
|
||||||
|
do: receive_resp(conn, ref, nil, nil, false)
|
||||||
receive_resp(conn, ref, nil, nil, false)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp receive_resp(conn, ref, status, data, done?) do
|
defp receive_resp(conn, ref, status, data, done?) do
|
||||||
|
|
Loading…
Reference in a new issue