Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #46

Merged
merged 2 commits into from
Jul 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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