Skip to content

Instantly share code, notes, and snippets.

@lpadukana
Created August 26, 2015 08:39
Show Gist options
  • Select an option

  • Save lpadukana/a98f4ca42f8443b9923e to your computer and use it in GitHub Desktop.

Select an option

Save lpadukana/a98f4ca42f8443b9923e to your computer and use it in GitHub Desktop.
# encoding: UTF-8
#\ -p 5000
header = { 'Content-Type' => 'text/plain' }
hello = ->(env) { [ 200, header, [ 'Hello World!' ] ] }
time = proc { |env| [ 200, header, [ Time.now.to_s ] ] }
date = Proc.new { |env| [ 200, header, [ Date.today.to_s ] ] }
random = lambda { |env| [ 200, header, [ rand(1000000).to_s ] ] }
class Environment
def call(env)
[ 200, {}, [ env.to_s ] ]
end
end
map '/' do
run hello
end
map '/hello' do
run hello
end
map '/env' do
run Environment.new
end
map '/time' do
run time
end
map '/date' do
run date
end
map '/random' do
run random
end
map '/temporal' do
run time
map '/time' do
run time
end
map '/date' do
run date
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment