macournoyer / thin

A very fast & simple Ruby web server

This URL has Read+Write access

Dan Kubb (author)
Fri Jul 18 12:40:18 -0700 2008
macournoyer (committer)
Sat Jul 19 06:34:08 -0700 2008
commit  affccc93679a419c8fca2f92fc11e006687bdf15
tree    f2bdb3301514db8c1e743a5b7bdd3d721765e567
parent  f99bd54ab90485a5be1bdb3f86600f5fc68728a9
thin / example / adapter.rb
100644 33 lines (29 sloc) 0.693 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Run with: ruby adapter.rb
# Then browse to http://localhost:3000/test
# and http://localhost:3000/files/adapter.rb
require File.dirname(__FILE__) + '/../lib/thin'
 
class SimpleAdapter
  def call(env)
    body = ["hello!"]
    [
      200,
      { 'Content-Type' => 'text/plain' },
      body
    ]
  end
end
 
Thin::Server.start('0.0.0.0', 3000) do
  use Rack::CommonLogger
  map '/test' do
    run SimpleAdapter.new
  end
  map '/files' do
    run Rack::File.new('.')
  end
end
 
# You could also start the server like this:
#
# app = Rack::URLMap.new('/test' => SimpleAdapter.new,
# '/files' => Rack::File.new('.'))
# Thin::Server.start('0.0.0.0', 3000, app)
#