-
-
25 Mar 2022 17:42:05 UTC
- Distribution: Mojolicious-Plugin-Geolocation-MMDB
- Module version: 0.003
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository (git clone)
- Issues
- Testers (306 / 0 / 8)
- Kwalitee
Bus factor: 1- 93.94% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (13.03KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- NAME
- VERSION
- SYNOPSIS
- DESCRIPTION
- HELPERS
- SUBROUTINES/METHODS
- DIAGNOSTICS
- CONFIGURATION AND ENVIRONMENT
- DEPENDENCIES
- INCOMPATIBILITIES
- AUTHOR
- BUGS AND LIMITATIONS
- LICENSE AND COPYRIGHT
NAME
Mojolicious::Plugin::Geolocation::MMDB - Look up location information by IP address
VERSION
version 0.003
SYNOPSIS
use Mojolicious::Lite -signatures; plugin 'Geolocation::MMDB', {file => 'Country.mmdb'}; get '/' => sub ($c) { my $location = $c->geolocation; my $country = eval { $location->{country}->{names}->{en} } // 'unknown location'; $c->render(text => "Welcome visitor from $country"); }; app->start;
DESCRIPTION
This Mojolicious plugin provides a helper that maps IPv4 and IPv6 addresses to location information such as country and city names.
HELPERS
geolocation
my $request_location = $c->geolocation; my $arbitrary_location = $c->geolocation('1.2.3.4');
If no IP address is given, the location of the current transaction's remote address is looked up. Otherwise, the specified IP address is looked up. Returns the undefined value if no location information is available for the IP address. Dies if the address is not a valid IP address.
SUBROUTINES/METHODS
register
$plugin->register(Mojolicious->new, {file => 'City.mmdb'});
Registers the plugin in a Mojolicious application. The "file" parameter is required.
DIAGNOSTICS
CONFIGURATION AND ENVIRONMENT
If your application is behind a reverse proxy, the environment variable
MOJO_REVERSE_PROXY
needs to bet set. See Mojolicious::Guides::Cookbook for more information.DEPENDENCIES
Requires the Perl modules Mojolicious and IP::Geolocation::MMDB from CPAN.
Requires an IP to country, city or ASN database in the MaxMind DB file format from MaxMind or DP-IP.com.
INCOMPATIBILITIES
None.
AUTHOR
Andreas Vögele <voegelas@cpan.org>
BUGS AND LIMITATIONS
None known.
LICENSE AND COPYRIGHT
Copyright 2022 Andreas Vögele
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Mojolicious::Plugin::Geolocation::MMDB, copy and paste the appropriate command in to your terminal.
cpanm Mojolicious::Plugin::Geolocation::MMDB
perl -MCPAN -e shell install Mojolicious::Plugin::Geolocation::MMDB
For more information on module installation, please visit the detailed CPAN module installation guide.