slimmer 13.3.0 → 13.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/slimmer/app.rb +15 -25
- data/lib/slimmer/headers.rb +0 -6
- data/lib/slimmer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b585bacc031b338e7fc26d91031217d8f9fd5d941f1ef7f0c7ed22570d8ca3d8
|
4
|
+
data.tar.gz: 0d887cb3278b139200586f525c0ad225c76aa0680f667a1d53ccd08555380c83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82f4f5819b2c58bf7609409342705cb326298b85532dc6a7e2731af5c8629b4b5bd1195797a2358fa6a959840a3d80bc9089e20659781c23ba91eff8419ffae7
|
7
|
+
data.tar.gz: 3de1edffa193308ff1e370e617dc7d503cec26398bdfe383edec856875ac0b6b4dba33ff975cc90adc3885688393d738452e5faf143578202d54b75fe8981693
|
data/CHANGELOG.md
CHANGED
data/lib/slimmer/app.rb
CHANGED
@@ -64,10 +64,6 @@ module Slimmer
|
|
64
64
|
!!response.headers[Headers::SKIP_HEADER]
|
65
65
|
end
|
66
66
|
|
67
|
-
def ignore_error_header?(response)
|
68
|
-
!!response.headers[Headers::IGNORE_ERROR_HEADER]
|
69
|
-
end
|
70
|
-
|
71
67
|
def s(body)
|
72
68
|
return body.to_s unless body.respond_to?(:each)
|
73
69
|
|
@@ -88,32 +84,26 @@ module Slimmer
|
|
88
84
|
# Store the request id so it can be passed on with any template requests
|
89
85
|
GovukRequestId.value = env["HTTP_GOVUK_REQUEST_ID"]
|
90
86
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
87
|
+
rewritten_body = case response.status
|
88
|
+
when 200
|
89
|
+
@skin.success request, response, s(response.body)
|
90
|
+
when 403
|
91
|
+
@skin.error "403", s(response.body), request.env
|
92
|
+
when 404
|
93
|
+
@skin.error "404", s(response.body), request.env
|
94
|
+
when 410
|
95
|
+
@skin.error "410", s(response.body), request.env
|
96
|
+
else
|
97
|
+
@skin.error "500", s(response.body), request.env
|
98
|
+
end
|
99
|
+
|
100
|
+
rewritten_body = [rewritten_body] unless rewritten_body.respond_to?(:each)
|
101
|
+
response.body = rewritten_body
|
95
102
|
response.headers["Content-Length"] = content_length(response.body)
|
96
103
|
|
97
104
|
response.finish
|
98
105
|
end
|
99
106
|
|
100
|
-
def rewritten_body(request, response)
|
101
|
-
return @skin.success request, response, s(response.body) if ignore_error_header?(response)
|
102
|
-
|
103
|
-
case response.status
|
104
|
-
when 200
|
105
|
-
@skin.success request, response, s(response.body)
|
106
|
-
when 403
|
107
|
-
@skin.error "403", s(response.body), request.env
|
108
|
-
when 404
|
109
|
-
@skin.error "404", s(response.body), request.env
|
110
|
-
when 410
|
111
|
-
@skin.error "410", s(response.body), request.env
|
112
|
-
else
|
113
|
-
@skin.error "500", s(response.body), request.env
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
107
|
def strip_slimmer_headers(headers)
|
118
108
|
headers.reject { |k, _v| k =~ /\A#{Headers::HEADER_PREFIX}/ }
|
119
109
|
end
|
data/lib/slimmer/headers.rb
CHANGED
@@ -20,7 +20,6 @@ module Slimmer
|
|
20
20
|
skip: "Skip",
|
21
21
|
template: "Template",
|
22
22
|
remove_search: "Remove-Search",
|
23
|
-
ignore_error: "Ignore-Error",
|
24
23
|
}.freeze
|
25
24
|
|
26
25
|
# @private
|
@@ -56,15 +55,10 @@ module Slimmer
|
|
56
55
|
# @private
|
57
56
|
REMOVE_SEARCH_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:remove_search]}".freeze
|
58
57
|
|
59
|
-
# @private
|
60
|
-
IGNORE_ERROR_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:ignore_error]}".freeze
|
61
|
-
|
62
|
-
|
63
58
|
# Set the "slimmer headers" to configure the page
|
64
59
|
#
|
65
60
|
# @param hash [Hash] the options
|
66
61
|
# @option hash [String] application_name
|
67
|
-
# @option hash [String] ignore_error
|
68
62
|
# @option hash [String] format
|
69
63
|
# @option hash [String] organisations
|
70
64
|
# @option hash [String] page_owner
|
data/lib/slimmer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 13.
|
4
|
+
version: 13.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|