Skip to content

Instantly share code, notes, and snippets.

@nu7hatch
Created August 11, 2010 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nu7hatch/519688 to your computer and use it in GitHub Desktop.
Save nu7hatch/519688 to your computer and use it in GitHub Desktop.
Example server writen with Telegraph framework
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