Skip to content
This repository has been archived by the owner. It is now read-only.
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

grails-geoip

Build Status Analytics

Grails GeoIP Plugin (based on MaxMind library)

Summary

This plugin facilitates grails integration with the opensource GeoIP framework offered by MaxMind. Using its straightforward API one can find out the country, area, city, geographical coordinates and others based on an IP.

Installation

Add the following plugin definition to your BuildConfig:

…
plugins {
…
	compile ':geoip:0.3.3'
…
}

Then run script to download and install free GeoLite database:

grails install-geo-data

Usage

The plugin adds a dynamic method to your controllers to determine location of client is accessing the app:

isInCountry(String countryCode) (where countryCode is ISO 3166 Country Code) will be true if the client use IP from this country.

def list() {
	...
	if (isInCountry('US')) {
		render(view: 'usa')
	} else {
		render(view: 'default')
	}
}

Additionally, you can run code conditionally, with access to the current com.maxmind.geoip.Location instance, with this method:

withLocation(Closure closure)

def list() {
	...
	def view = 'list'
	withLocation { location ->
		view = "list_${location.countryCode}"
	}
	render(view: view, model: [list: listInstance])
}

Copyright and license

Copyright 2009-2013 Radu Andrei Tanasa, Alexey Zhokhov under the GNU Lesser General Public License, version 2.1. Supported by AZ.

This product includes GeoLite data created by MaxMind, available from www.maxmind.com.

About

Grails GeoIP Plugin (based on MaxMind library)

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.