getting the following error
** (UndefinedFunctionError) function MyWeb.GeolocationController.index/2 is undefined or privat
geolocation
defmodule MyWeb.Geolocation do
def geo_data(ip) when is_binary(ip) do
geo_url = Application.get_env(:myweb, :geo_url)
case HTTPoison.get!("#{geo_url}#{URI.encode_www_form(ip)}") do
%HTTPoison.Response{body: body, status_code: 200} ->
body
%HTTPoison.Response{status_code: status_code} when status_code > 399 ->
IO.inspect(status_code, label: "STATUS_CODE")
:error
_response ->
raise MyWeb.Error
end
end
end
controller
defmodule MyWebWeb.GeoController do
use MyWebWeb, :controller
import MyWeb.Geolocation
def index(conn, ip, _params) do
send_resp(conn, 200, geo_data(ip))
end
end
router
get "/geo/:ip", GeoController, :index