Skip to content

Instantly share code, notes, and snippets.

@gorsuch
Created March 30, 2011 02:51
Show Gist options
  • Save gorsuch/893771 to your computer and use it in GitHub Desktop.
Save gorsuch/893771 to your computer and use it in GitHub Desktop.
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