Permalink
Browse files

don't set cache headers for protected actions

  • Loading branch information...
1 parent 0a5afd7 commit 8815f17b57e30dfd0a01db3f10cacb2216102c23 @nakajima committed Feb 1, 2009
Showing with 6 additions and 2 deletions.
  1. +2 −2 lib/sinatras-hat/actions.rb
  2. +4 −0 lib/sinatras-hat/maker.rb
View
4 lib/sinatras-hat/actions.rb
@@ -33,7 +33,7 @@ def self.included(map)
map.action :show, '/:id' do |request|
record = model.find(request.params) || responder.not_found(request)
- set_cache_headers(request, record)
+ set_cache_headers(request, record) unless protected?(:show)
responder.success(:show, request, record)
end
@@ -45,7 +45,7 @@ def self.included(map)
map.action :index, '/' do |request|
records = model.all(request.params)
- set_cache_headers(request, records)
+ set_cache_headers(request, records) unless protected?(:index)
responder.success(:index, request, records)
end
View
4 lib/sinatras-hat/maker.rb
@@ -140,6 +140,10 @@ def resource
private
+ def protected?(action)
+ protect.include?(action)
+ end
+
def log_with_benchmark(request, action)
msg = [ ]
msg << "#{request.env['REQUEST_METHOD']} #{request.env['PATH_INFO']}"

0 comments on commit 8815f17

Please sign in to comment.