Skip to content
Permalink
Browse files

set cache_control header"

  • Loading branch information...
mscoutermarsh committed Dec 4, 2015
1 parent d8cd1c5 commit 4aed5968c7b43ab61fe5c918f637353b420f48a8
Showing with 5 additions and 2 deletions.
  1. +1 −0 app.rb
  2. +3 −2 app/routes/image.rb
  3. +1 −0 spec/routes/image_spec.rb
1 app.rb
@@ -13,6 +13,7 @@
require 'sinatra/base'
require 'base64'
require 'openssl'
require 'pry-byebug' if ENV['RACK_ENV'] == 'development'

require 'app/image_templates/base'
Dir['app/image_templates/*.rb'].each { |file| require file }
@@ -20,12 +20,13 @@ class Image < Sinatra::Application
end

get '/v1/:encoded_params/:encoded_hmac_digest/image.jpg' do
content_type :jpeg

unless authorized?(encoded_params: params[:encoded_params], encoded_hmac_digest: params[:encoded_hmac_digest])
halt 401, 'Not authorized'
end

content_type :jpeg
cache_control :public, max_age: 31536000

decoded_params = Base64.urlsafe_decode64(params[:encoded_params])
ShareMeow::Image.new(JSON.parse(decoded_params)).to_jpg
end
@@ -41,6 +41,7 @@

expect(ShareMeow::Image).to have_received(:new).with('template' => 'HelloWorld', 'message' => 'Hello, World')
end

context 'invalid key' do
let(:secret_key) { 'thisiswrong' }

0 comments on commit 4aed596

Please sign in to comment.
You can’t perform that action at this time.