BoxLang 🚀 A New JVM Dynamic Language Learn More...
This module will retrieve geolocation information for a specific user's ip address using the API available at https://www.ipinfodb.com.
The following and more information will be retrieved for you:
<cfdump var="#getModel( 'GeoLocation@GeoLocation' ).getLocation()#">
Please note the cached
key which will denote if the lookup is a fresh lookup or a cached request.
Apache License, Version 2.0.
Use CommandBox to install
box install GeoLocation-lookup-by-IP
You can then continue to configure the module in your config/Coldbox.cfc
.
moduleSettings = {
"GeoLocation-lookup-by-IP" : {
// Cache subsequent ip address lookups for performance
cache : true,
// How many minutes to cache the IP lookup
cacheTimeout : "60",
// The default cache provider to use
cacheName : "default",
// The cache prefix to use on all ip keys
cacheKeyPrefix : "GeoLocation-",
// Register here for free:
// https://www.ipinfodb.com
developerKey : ""
}
}
You can retrieve the main model via injection or requesting it from WireBox using the following DSL
GeoLocation@GeoLocation
There are two two public methods that you can use
getLocation()
- To get a location from an IP AddressclearCache()
- To clear the geo cacheYou can also use our handy mixin called: getGeoLocation()
from any handler, interceptor, layout or view.
var result = geoLocation.getLocation();
By default, it will use the IP address obtained from the CGI scope (taking into account a forwarded request). By default, this method will also cache the result in your default CacheBox provider for 60 minutes.
This method takes the following optional parameters that override the module defaults:
IPAddress
cache
This method will clear out any items in the cache that it put there.
This code comes with no warranties, promises, or rainbows. In fact, it will probably kick your cat.
Brad Wood
Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com
Because of His grace, this project exists. If you don't like this, then don't read it, its not for you.
"Therefore being justified by faith, we have peace with God through our Lord Jesus Christ: By whom also we have access by faith into this grace wherein we stand, and rejoice in hope of the glory of God. And not only so, but we glory in tribulations also: knowing that tribulation worketh patience; And patience, experience; and experience, hope: And hope maketh not ashamed; because the love of God is shed abroad in our hearts by the Holy Ghost which is given unto us. ." Romans 5:5
"I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
getGeoLocation()
cached
key in the resposne to denote if the lookup is fresh or cached
$
box install GeoLocation-lookup-by-IP