Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phaneesh/dropwizard-maxmind-bundle
A simple bundle for integrating MaxMind into dropwizard
https://github.com/phaneesh/dropwizard-maxmind-bundle
Last synced: about 2 months ago
JSON representation
A simple bundle for integrating MaxMind into dropwizard
- Host: GitHub
- URL: https://github.com/phaneesh/dropwizard-maxmind-bundle
- Owner: phaneesh
- Created: 2016-04-24T07:42:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-12-21T12:59:46.000Z (about 4 years ago)
- Last Synced: 2024-04-11T06:41:24.017Z (9 months ago)
- Language: Java
- Size: 35.2 KB
- Stars: 6
- Watchers: 3
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-dropwizard - dropwizard-maxmind-bundle - MaxMind GeoIP2 support for dropwizard (Open Source / Eclipse)
README
# Dropwizard MaxMind Bundle [![Travis build status](https://travis-ci.org/phaneesh/dropwizard-maxmind-bundle.svg?branch=master)](https://travis-ci.org/phaneesh/dropwizard-maxmind-bundle)
This bundle adds MaxMind GeoIP2 support for dropwizard.
This bundle compiles only on Java 8.## Dependencies
* Dropwizard 1.3.13
* [GeoIP2 Java API](https://github.com/maxmind/GeoIP2-java)## Usage
The bundle adds MaxMind GeoIP2 support for which makes it easier for geo ip information that is required by location aware services.
The bundle works with the free light version of MaxMind GeoIP2 database as well.### Build instructions
- Clone the source:git clone github.com/phaneesh/dropwizard-maxmind-bundle
- Build
mvn install
### Maven Dependency
Use the following repository:
```xmlclojars
Clojars repository
https://clojars.org/repo```
Use the following maven dependency:
```xmlio.dropwizard
dropwizard-maxmind
1.3.7```
### Using MaxMind bundle
#### Configuration
```yaml
maxmind:
databaseFilePath: /path/to/maxmind/database/file.mmdb
remoteIpHeader: "CLIENT-IP" #default is X-FORWARDED-FOR (when used behind a loadbalancer)
cacheTTL: 120 #In seconds, Default is 300 seconds
cacheMaxEntries: 102400 #Default is 10240
enterprise: true #default: false. Enable maxmind enterprise database mode
type: anonymous #If it is not a enterprise database; set the type of database that is being used. Supported: country, city, anonymous
maxMindContext: false #If you need MaxMindInfo injection into resource methods; set it to true
```#### Bootstrap
```java
@Override
public void initialize(final Bootstrap...) {
bootstrap.addBundle(new MaxMindBundle() {
public MaxMindConfig getMaxMindConfig(T configuration) {
...
}
});
}
```#### Headers stamped
* X-MAXMIND-REQUEST-COUNTRY
* X-MAXMIND-REQUEST-COUNTRY-ISO
* X-MAXMIND-REQUEST-STATE
* X-MAXMIND-REQUEST-STATE-ISO
* X-MAXMIND-REQUEST-CITY
* X-MAXMIND-REQUEST-POSTAL-CODE
* X-MAXMIND-REQUEST-LATITUDE
* X-MAXMIND-REQUEST-LONGITUDE
* X-MAXMIND-REQUEST-LOCATION-ACCURACY
* X-MAXMIND-REQUEST-USER-TYPE
* X-MAXMIND-REQUEST-CONNECTION-TYPE
* X-MAXMIND-REQUEST-ISP
* X-MAXMIND-REQUEST-ANONYMOUS-IP
* X-MAXMIND-REQUEST-ANONYMOUS-VPN
* X-MAXMIND-REQUEST-TOR-NODE
* X-MAXMIND-REQUEST-LEGAL-PROXY#### MaxMindContext in Resource
Use MaxMindInfo which is much more convenient if you want easier access to all the stamped headers in a simple object model
* Example```java
@Produces({ MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_JSON })
@Path("/")
public class MaxMindResource {@GET
public Response maxMindInfoApi(@MaxMindContext final MaxMindInfo maxMindInfo) {
// Do work and return something
return Response.status(OK).entity(maxMindInfo).build();
}
}
```LICENSE
-------Copyright 2016 Phaneesh Nagaraja .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.