summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Beauchamp <daniel.beauchamp@shopify.com>2012-07-31 01:42:38 -0400
committerDaniel Beauchamp <daniel.beauchamp@shopify.com>2012-07-31 01:42:38 -0400
commit1dcf732b801f9fa513901fda27388a36eddb44ab (patch)
tree08bfadb8c57c5a3caa69ea73f5e442d80a9e0681 /lib
parent8bd42014dfbc0fa1b34ebf6521c4662beba191f5 (diff)
Added support for authentication.
Diffstat (limited to 'lib')
-rw-r--r--lib/allthethings.rb10
1 files changed, 10 insertions, 0 deletions
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")