A simple elixir library for ipify: A Simple IP Address API.
ElixirIpify is available in Hex, the package can be installed as:
- Add
elixir_ipify
to your list of dependencies inmix.exs
:
```elixir
def deps do
[{:elixir_ipify, "~> 0.1.0"},
{:httpotion, "~> 3.0.0"}]
end
def application do
[applications: [:logger,:elixir_ipify]]
end
```
- Run the mix command:
```bash
$ mix deps.get
```
- Open your interactive elixir shell:
```bash
$ iex -S mix
```
- Try the functions:
```code
iex()> ElixirIpify.fetch
"1.2.3.4" # if success
iex()> ElixirIpify.fetch
"Nothing goes wrong!" # if error
```
-
You can get also elixir style response:
iex()> ElixirIpify.get {:ok, "1.2.3.4"} # if success iex()> ElixirIpify.get {:error, "Nothing goes wrong!"} # if error
MIT © Zoltán Gabulya