From 1dcf732b801f9fa513901fda27388a36eddb44ab Mon Sep 17 00:00:00 2001 From: Daniel Beauchamp Date: Tue, 31 Jul 2012 01:42:38 -0400 Subject: Added support for authentication. --- lib/allthethings.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/allthethings.rb b/lib/allthethings.rb index cf4a62a..904a991 100644 --- a/lib/allthethings.rb +++ b/lib/allthethings.rb @@ -19,7 +19,14 @@ def configure(&block) instance_eval(&block) end +helpers do + def protected! + # override with auth logic + end +end + get '/events', provides: 'text/event-stream' do + protected! stream :keep_open do |out| settings.connections << out out << latest_events @@ -36,15 +43,18 @@ get '/' do end get '/:dashboard' do + protected! erb params[:dashboard].to_sym end get '/views/:widget?.html' do + protected! widget = params[:widget] send_file File.join(Dir.pwd, "widgets/#{widget}/#{widget}.html") end post '/widgets/:id' do + protected! request.body.rewind body = JSON.parse(request.body.read) auth_token = body.delete("auth_token") -- cgit v1.2.3