diff --git a/README.md b/README.md index cfadb40..85c570f 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ 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: @@ -36,6 +36,24 @@ Then clone the repository, run `make shell` and declare your key: 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: +``` + #### 2\. Start the database loader ``` erlang @@ -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 @@ -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)