Skip to content

Instantly share code, notes, and snippets.

@amidvidy
Last active December 15, 2015 23:49
Show Gist options
  • Save amidvidy/5342673 to your computer and use it in GitHub Desktop.
Save amidvidy/5342673 to your computer and use it in GitHub Desktop.
bloom http example
module BloomHttpAPIExample
state do
http(:req, :resp) :hello_world, [:query_param1, :query_param2, ...]
end
bloom do
# we could also use some kind of template mechanism
hello_world.resp <= hello_world.req { |r| [["<html><p>Your ip is #{r.remote_addr}</p></html>"]] }
end
end
class Server
include BloomHttpApiExample
include Bud
end
s = Server.new(:port => 8000).run_bg
----------------------
// Then in the browser, go to http://localhost:8000/hello_world
Your ip is 127.0.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment