Giter Site home page Giter Site logo

patrick-a-cavanaugh / rack-geoipcountry Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tma/rack-geoipcountry

0.0 1.0 0.0 72 KB

Rack::GeoIPCountry uses the geoip gem and the GeoIP database to lookup the country of a request by its IP address

Home Page: http://coderack.org/users/hosiawak/middlewares/36-geoip-country

rack-geoipcountry's Introduction

Rack::GeoIPCountry uses the geoip gem and the GeoIP database to lookup the country of a request by its IP address

The database can be downloaded from:

http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz

Usage

use Rack::GeoIPCountry, :db => "path/to/GeoIP.dat"

By default all requests are looked up and the X_GEOIP_* headers are added to the request The headers can then be read in the application. The country name is added to the request header as X_GEOIP_COUNTRY, eg: X_GEOIP_COUNTRY: United Kingdom

The full set of GEOIP request headers is below:

  • X_GEOIP_COUNTRY_ID - The GeoIP country-ID as an integer, if not found set to 0
  • X_GEOIP_COUNTRY_CODE - The ISO3166-1 two-character country code, if not found set to --
  • X_GEOIP_COUNTRY_CODE3 - The ISO3166-2 three-character country code, if not found set to --
  • X_GEOIP_COUNTRY - The ISO3166 English-language name of the country, if not found set to N/A
  • X_GEOIP_CONTINENT - The two-character continent code, if not found set to --

You can use the included Mapping class to trigger lookup only for certain requests by specifying matching path prefix in options, eg:

use Rack::GeoIPCountry::Mapping, :prefix => '/video_tracking'

The above will lookup IP addresses only for requests matching /video_tracking etc.

License

MIT License - Karol Hosiawa ( http://twitter.com/hosiawak )

rack-geoipcountry's People

Contributors

tma avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.