Skip to content

Instantly share code, notes, and snippets.

@denysxftr
Created August 18, 2015 22:03
Show Gist options
  • Save denysxftr/7c6a2829dd0505fa5fcc to your computer and use it in GitHub Desktop.
Save denysxftr/7c6a2829dd0505fa5fcc to your computer and use it in GitHub Desktop.
require 'rack'
require 'json'
class ApiApp
def initialize
@views = {}
end
def call(env)
req = Rack::Request.new(env)
@views[req.path] ||= 0
@views[req.path] += 1
response
end
def response
[
200,
{'Content-type' => 'application/json'},
[{ views: @views }.to_json]
]
end
end
Rack::Handler::WEBrick.run(ApiApp.new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment