bmizerany (owner)

Revisions

gist: 118217 Download_button fork
public
Public Clone URL: git://gist.github.com/118217.git
Embed All Files: show embed
config.ru (as plain Rack) #
1
2
3
4
use Rack::ContentType, "text/plain"
use Rack::ContentLength
 
run lambda {|env| [200, {}, [env['REMOTE_ADDR'].split(",").first]]}
config.ru (as Sinatra) #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
require 'sinatra/base'
 
run Sinatra.new {
  get('/') do
    content_type "text/plain" # you can also use Rack::ContentType
                              # with Sinatra except here we want
                              # more control since Sinatra gives it
                              # to us. Rack::ContentType sets the
                              # Content-Type on every route/url for
                              # the current mapping.
 
    request.env['REMOTE_ADDR'].split(",").first
  end
}