Last active
December 15, 2015 23:49
-
-
Save amidvidy/5342673 to your computer and use it in GitHub Desktop.
bloom http example
This file contains 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
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