set vary header and cache documentation

This commit is contained in:
Konstantin Haase 2012-09-25 17:52:52 +02:00
parent e8d2604ec3
commit 603c32b097
2 changed files with 5 additions and 1 deletions

View File

@ -4,7 +4,7 @@ class Travis::Api::App
class Endpoint
# Generated API documentation.
class Documentation < Endpoint
set prefix: '/docs', public_folder: File.expand_path('../documentation', __FILE__)
set prefix: '/docs', public_folder: File.expand_path('../documentation', __FILE__), static_cache_control: :public
enable :inline_templates, :static
# Don't cache general docs in development
@ -12,6 +12,7 @@ class Travis::Api::App
# HTML view for [/endpoints](#/endpoints/).
get '/' do
cache_control :public
content_type :html
endpoints = Endpoints.endpoints
erb :index, {}, endpoints: endpoints.keys.sort.map { |k| endpoints[k] }

View File

@ -33,6 +33,9 @@ class Travis::Api::App
headers['X-Accepted-OAuth-Scopes'] = name.to_s
if scopes.include? name
headers['Vary'] = 'Accept'
headers['Vary'] << ', Authorization' if scope == :public
#cache_control :public, :must_revalidate if request.head? or request.get?
true
elsif logged_in?
halt 403, "insufficient access"