Class: Rack::Geo

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/geo.rb,
lib/rack/geo/version.rb

Defined Under Namespace

Modules: VERSION Classes: Position

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Geo

Returns a new instance of Geo.



5
6
7
# File 'lib/rack/geo.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
# File 'lib/rack/geo.rb', line 9

def call(env)
  position = Position.new(env["HTTP_GEO_POSITION"] || env["HTTP_X_GEO_POSITION"])
  env["geo.position"] = position if position.valid?
  @app.call(env)
end