package Mojolicious::Plugin::Geo;
use Mojo::Base 'Mojolicious::Plugin';
use Mojo::UserAgent;

our $VERSION = '0.02';

sub register {
    my ($self, $app) = @_;

    $app->helper(geo => sub {
        my ($self,$ip) = @_;

        my $ua = Mojo::UserAgent->new;      

        my $ip_info = $ua->get('' . $ip)->res->body;  
        my %data = map  { (split /=/, $_) } split(/&/, $ip_info);       

        return \%data;


=head1 NAME

Mojolicious::Plugin::Geo - Mojolicious Plugin


  # Mojolicious

  # Mojolicious::Lite
  plugin 'geo';


L<Mojolicious::Plugin::Geo> is a L<Mojolicious> plugin.
This plugin uses a geolocation server of an unknown provider. It is one of the more accurate I have found. I may add some free public ones later but have not had a chance.

=head1 METHODS

L<Mojolicious::Plugin::Geo> inherits all methods from
L<Mojolicious::Plugin> and implements the following new ones.

=head2 C<geo>


    Returns an object with basic geo data. Lat, Lon, City, Country, Postal Code etc..

Register plugin in L<Mojolicious> application.

=head1 SEE ALSO

L<Mojolicious>, L<Mojolicious::Guides>, L<>.