Last active
December 21, 2015 04:19
-
-
Save benvds/6248662 to your computer and use it in GitHub Desktop.
use of basic auth disables before block
This file contains hidden or 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
require 'sinatra/base' | |
class TestRestApi < Sinatra::Base | |
before do | |
headers['Access-Control-Allow-Origin'] = '*' | |
content_type :json | |
end | |
# no more header & content_type when to following is enabled | |
use Rack::Auth::Basic, "Restricted Area" do |username, password| | |
username == 'admin' and password == 'secret' | |
end | |
# ... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment