Skip to content

Commit

Permalink
Update README.md (#46)
Browse files Browse the repository at this point in the history
Fix reference to MaxMind license key section, and add setup instructions
for Elixir.
  • Loading branch information
g-andrade authored Jul 20, 2024
2 parents df4c5ca + 9e3097f commit 3252d61
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,32 @@ MaxMind.*

Get a free [license key](https://www.maxmind.com/en/geolite2/signup)
from MaxMind if you haven't one already. Once logged in, you'll find the
page to generate it on the left menu, under "My License Key".
page to generate it on the left menu, under "Manage License Keys".

Then clone the repository, run `make shell` and declare your key:

``` erlang
application:set_env(locus, license_key, "YOUR_LICENSE_KEY").
```

If you're using Elixir, add locus as a dependency to your mix project:

```elixir
defp deps do
[
...
{:locus, "~> 2.3"}
]
end
```

Then, configure your license key in `config.exs`:

```elixir
config :locus,
license_key: <MAXMIND_API_KEY>
```

#### 2\. Start the database loader

``` erlang
Expand All @@ -47,6 +65,17 @@ ok = locus:start_loader(country, {maxmind, "GeoLite2-Country"}).
% implementing the locus_custom_fetcher behaviour.
```

Or, in Elixir, start the database loaders that you'll be using in `application.ex`:

```elixir
def start(_type, _args) do
# :locus.start_loader(:asn, {:maxmind, "GeoLite2-ASN"})
# :locus.start_loader(:country, {:maxmind, "GeoLite2-Country"})
:locus.start_loader(:city, {:maxmind, "GeoLite2-City"})

...
```

#### 3\. Wait for the database to load (optional)

``` erlang
Expand Down Expand Up @@ -102,6 +131,17 @@ ok = locus:start_loader(country, {maxmind, "GeoLite2-Country"}).
<<"zh-CN">> => <<"美国"/utf8>>}}}}
```

Or, in Elixir, call the erlang library from your Elixir application:

```elixir
iex> :locus.lookup(:city, "93.184.216.34")
{:ok,
%{
"city" => %{"geoname_id" => 4945936, "names" => %{"en" => "Norwell"}},
...
}}
```

## Documentation

1. [Supported File Formats](#supported-file-formats)
Expand Down

0 comments on commit 3252d61

Please sign in to comment.