Created
March 30, 2011 02:51
-
-
Save gorsuch/893771 to your computer and use it in GitHub Desktop.
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
require 'cuba' | |
Cuba.define do | |
on "api/v1" do | |
auth = Rack::Auth::Basic::Request.new(req.env) | |
authorized = auth.provided? && auth.basic? && auth.credentials && auth.credentials == ['admin', 'admin'] | |
if !authorized | |
res['WWW-Authenticate'] = %(Basic realm="Restricted Area") | |
res.status = 401 | |
else | |
on "bugs" do | |
res.write "stuff" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment