diff --git a/application.rb b/application.rb index b5bfe335..f62b9881 100644 --- a/application.rb +++ b/application.rb @@ -2,7 +2,7 @@ class Application def call(env) resp = Rack::Response.new - resp.write "Hello, World" + resp.write "Hello, my name is" resp.finish end diff --git a/first.ru b/first.ru new file mode 100644 index 00000000..27a87ff1 --- /dev/null +++ b/first.ru @@ -0,0 +1,9 @@ +require 'rack' + +# Instances of Proc automatically have a call method that runs the block that +# they're initialized with. +my_server = Proc.new do + [200, { 'Content-Type' => 'text/html' }, ['Hello']] +end + +run my_server \ No newline at end of file diff --git a/second.ru b/second.ru new file mode 100644 index 00000000..415e72da --- /dev/null +++ b/second.ru @@ -0,0 +1,14 @@ +require 'rack' + +# Something that responds to call, that's what Rack demands +class MyServer + def call(env) + return [ 200, {'Content-Type' => 'text/html'}, "Hello, my name is" ] + end + + def pretty_response + (Time.now.to_i % 2).zero? ? ["Hello"] : ["Hello"] + end +end + +run MyServer.new \ No newline at end of file diff --git a/third.ru b/third.ru new file mode 100644 index 00000000..ab09a0f8 --- /dev/null +++ b/third.ru @@ -0,0 +1,2 @@ +require_relative './my_server' +run MyServer.new