Fakultas Ilmu Komputer UI

Commit 7d8c2f24 authored by Muhammad Rafif Elfazri's avatar Muhammad Rafif Elfazri
Browse files

Add proxy url ENV Variables

parent 2750df8b
......@@ -42,6 +42,9 @@ config :diskuy, DiskuyWeb.Auth.Guardian,
issuer: "diskuy",
secret_key: guardian_secret_key_base
config :diskuy, DiskuyWeb.Auth.GoogleAuth,
proxy: System.get_env("PROXY")
# ## Using releases (Elixir v1.9+)
# If you are doing OTP releases, you need to instruct Phoenix
......@@ -5,14 +5,23 @@ defmodule DiskuyWeb.Auth.GoogleAuth do
@google_user_profile "https://www.googleapis.com/oauth2/v3/userinfo"
@spec get_user_profile(String.t) :: String.t
def get_user_profile(token) do
|> HTTPoison.get()
|> handle_get_proxy()
|> parse_body_response()
@spec parse_body_response({atom, String.t}) :: String.t
defp handle_get_proxy(url) do
case Application.get_env(:diskuy, :proxy) do
nil ->
proxy ->
HTTPoison.get(url, [], [{:proxy, proxy}])
def parse_body_response({:error, err}), do: {:error, err}
def parse_body_response({:ok, response}) do
body = Map.get(response, :body)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment