alephant-broker 3.4.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66e7169ca6dccf162a18d99cd370e664743f7368
4
- data.tar.gz: ed5178f9dc74b2f4b339ceffe9c2a1aff969c566
3
+ metadata.gz: fda6d6a6605e71b9eb66abf08dddb9d5e1baab44
4
+ data.tar.gz: cec4b99897a6bcbf1265586d48ef6bac5cd182e0
5
5
  SHA512:
6
- metadata.gz: d761eaba217f4f256ccd1544063d237624af19f4609d9880cfc09694d15c8767c80b423bc8974e6d235d9603c28e808f79d9f358a61b59bad4ca93e0674f324b
7
- data.tar.gz: 12b02ddece7cdd609f018b99a080e735bc57993ec472409bc492f6a68418f0bbd95c8635e37154ec92b87c2d62d56f33c999fcce06045df17b0a32cb6ea7df49
6
+ metadata.gz: de0065a472ec3619e4ff4ef17b05d797bf80d3a9653b63d635a37a9c76c2a5f86b01ae901d628cc8280d9c4b1437c2f97b0e48522816bd26b61147b805216edf
7
+ data.tar.gz: af56c9641a638cb8c2683f713774701530f7972e6bf53e29efe9d46ba3afab8832f353d9899128f1de7965160e061c9f0e58c982792aee35a1cb88f3a8c23201
@@ -1,7 +1,8 @@
1
- require 'alephant/broker/errors/invalid_cache_key'
2
- require 'alephant/logger'
3
- require 'aws-sdk'
4
- require 'ostruct'
1
+ require "alephant/broker/errors/invalid_cache_key"
2
+ require "alephant/logger"
3
+ require "aws-sdk"
4
+ require "ostruct"
5
+ require "date"
5
6
 
6
7
  module Alephant
7
8
  module Broker
@@ -12,9 +13,9 @@ module Alephant
12
13
  attr_reader :content, :headers, :status
13
14
 
14
15
  STATUS_CODE_MAPPING = {
15
- 200 => 'ok',
16
- 404 => 'Not found',
17
- 500 => 'Error retrieving content'
16
+ 200 => "ok",
17
+ 404 => "Not found",
18
+ 500 => "Error retrieving content"
18
19
  }
19
20
 
20
21
  def initialize(status = 200, content_type = "text/html")
@@ -22,8 +23,7 @@ module Alephant
22
23
  @headers = { "Content-Type" => content_type }
23
24
  @status = status
24
25
 
25
- log if status !~ /200/
26
-
26
+ log_status
27
27
  setup
28
28
  end
29
29
 
@@ -33,11 +33,27 @@ module Alephant
33
33
 
34
34
  private
35
35
 
36
+ def log_status
37
+ add_no_cache_headers if status !~ /200/
38
+ end
39
+
40
+ def add_no_cache_headers
41
+ headers.merge!(
42
+ "Cache-Control" => "no-cache, must-revalidate",
43
+ "Pragma" => "no-cache",
44
+ "Expires" => Date.today.prev_year.httpdate
45
+ )
46
+ log
47
+ end
48
+
36
49
  def log
37
- logger.metric(:name => "BrokerResponse#{status}", :unit => "Count", :value => 1)
50
+ logger.metric(
51
+ :name => "BrokerResponse#{status}",
52
+ :unit => "Count",
53
+ :value => 1
54
+ )
38
55
  end
39
56
  end
40
57
  end
41
58
  end
42
59
  end
43
-
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Broker
3
- VERSION = "3.4.1"
3
+ VERSION = "3.5.0"
4
4
  end
5
5
  end
@@ -59,6 +59,9 @@ describe Alephant::Broker::Application do
59
59
  before { get "/banana" }
60
60
  specify { expect(last_response.status).to eql 404 }
61
61
  specify { expect(last_response.body).to eq "Not found" }
62
+ specify { expect(last_response.headers).to include("Cache-Control") }
63
+ specify { expect(last_response.headers).to include("Pragma") }
64
+ specify { expect(last_response.headers).to include("Expires") }
62
65
  end
63
66
 
64
67
  describe "Component endpoint '/component/...'" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alephant-broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack