Last active
June 8, 2016 14:09
-
-
Save gaynetdinov/353dab9a444e9b42440c091537a3c3fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defp check_access(conn) do | |
parsed_body = with {:ok, response} <- HTTPoison.get(url, header_with_authorization(conn)), | |
200 <- response.status_code, | |
do: Poison.Parser.parse(response.body) | |
case parsed_body do | |
{:ok, %{"super_admin" => _} = body} -> | |
{:ok, body} | |
_ -> | |
{:error, "User not authorized"} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With Elixir 1.3 this code would look like this: