Created
August 11, 2010 20:27
-
-
Save nu7hatch/519688 to your computer and use it in GitHub Desktop.
Example server writen with Telegraph framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'telegraph' | |
before do | |
say "foo" | |
end | |
after(:foo) do | |
say "bar" | |
end | |
handle /^HELLO/ do | |
"HI DUDE!" # returned value is answer | |
end | |
handle /^TEST (.*)/, :with => [:test] do | |
session[:test] = params[:test] | |
say_ok # shortcut for say("OK") | |
say_foo_bar_test # shortcut for say("FOO_BAR_TEST") | |
end | |
handle :foo, :to => /^FOO .*/ do | |
say "This is SPARTA!" | |
say "Kick!" | |
session[:test] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment