Created
March 5, 2014 02:04
-
-
Save albertico/9359866 to your computer and use it in GitHub Desktop.
Goliath server with CORS middleware
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
#!/usr/bin/env ruby | |
require 'goliath' | |
class CORS | |
include Goliath::Rack::AsyncMiddleware | |
def post_process(env, status, headers, body) | |
headers['Access-Control-Allow-Origin'] = '*' | |
[status, headers, body] | |
end | |
end | |
class HelloWorld < Goliath::API | |
use CORS | |
def response(env) | |
[200, {}, "hello world"] | |
end | |
end | |
# ruby goliath_cors.rb -sv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment