Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't set cache headers for protected actions

  • Loading branch information...
commit 8815f17b57e30dfd0a01db3f10cacb2216102c23 1 parent 0a5afd7
Pat Nakajima authored
Showing with 6 additions and 2 deletions.
  1. +2 −2 lib/sinatras-hat/actions.rb
  2. +4 −0 lib/sinatras-hat/maker.rb
4 lib/sinatras-hat/actions.rb
View
@@ -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
4 lib/sinatras-hat/maker.rb
View
@@ -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']}"
Please sign in to comment.
Something went wrong with that request. Please try again.