Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rack'
- require 'json'
- require "active_support/core_ext/hash/conversions"
- class HelloWorld
- def call(env)
- req = Rack::Request.new(env)
- if req.content_type =~ /json/
- resp = env.to_json
- else
- resp = env.to_xml
- end
- return [200, {"Content-Type" => req.content_type}, [resp]]
- end
- end
- Rack::Handler::WEBrick.run(
- HelloWorld.new,
- :Port => 9000
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement