Permalink
Browse files
set cache_control header"
- Loading branch information...
Showing
with
5 additions
and
2 deletions.
-
+1
−0
app.rb
-
+3
−2
app/routes/image.rb
-
+1
−0
spec/routes/image_spec.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