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 +4 -4
- data/lib/alephant/broker/response/base.rb +27 -11
- data/lib/alephant/broker/version.rb +1 -1
- data/spec/integration/rack_spec.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fda6d6a6605e71b9eb66abf08dddb9d5e1baab44
|
4
|
+
data.tar.gz: cec4b99897a6bcbf1265586d48ef6bac5cd182e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de0065a472ec3619e4ff4ef17b05d797bf80d3a9653b63d635a37a9c76c2a5f86b01ae901d628cc8280d9c4b1437c2f97b0e48522816bd26b61147b805216edf
|
7
|
+
data.tar.gz: af56c9641a638cb8c2683f713774701530f7972e6bf53e29efe9d46ba3afab8832f353d9899128f1de7965160e061c9f0e58c982792aee35a1cb88f3a8c23201
|
@@ -1,7 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
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 =>
|
16
|
-
404 =>
|
17
|
-
500 =>
|
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
|
-
|
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(
|
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
|
-
|
@@ -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
|