slimmer 13.2.2 → 13.3.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 +25 -15
- data/lib/slimmer/headers.rb +6 -0
- 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: 29c95c6ec5fcb3d786e88628da00aa44018de1a338e49359d19088db092ea025
|
4
|
+
data.tar.gz: 5c2f32ef832e751dc5812af7cb9d388fd4a36c8bde03d9525f58b7a46b5f0e87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 111d7b5964863534428a2a6b9f46252f49624cb226c524e6c048cbff155c2a37d96cf14f85ade73d71b9b8bbeef1065596f9e795682f7f4fe913529fb0225116
|
7
|
+
data.tar.gz: 182cab20358b7ae4b69b17c11b19ddb6697e54bd94cd66575478bdc0fa11d6a03597d9788ec4c03b6da22f6ccbb5a4156042aaecb433b1c7ddc907c2e3b7934f
|
data/CHANGELOG.md
CHANGED
data/lib/slimmer/app.rb
CHANGED
@@ -64,6 +64,10 @@ 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
|
+
|
67
71
|
def s(body)
|
68
72
|
return body.to_s unless body.respond_to?(:each)
|
69
73
|
|
@@ -84,26 +88,32 @@ module Slimmer
|
|
84
88
|
# Store the request id so it can be passed on with any template requests
|
85
89
|
GovukRequestId.value = env["HTTP_GOVUK_REQUEST_ID"]
|
86
90
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
91
|
+
body = rewritten_body(request, response)
|
92
|
+
|
93
|
+
body = [body] unless body.respond_to?(:each)
|
94
|
+
response.body = body
|
102
95
|
response.headers["Content-Length"] = content_length(response.body)
|
103
96
|
|
104
97
|
response.finish
|
105
98
|
end
|
106
99
|
|
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
|
+
|
107
117
|
def strip_slimmer_headers(headers)
|
108
118
|
headers.reject { |k, _v| k =~ /\A#{Headers::HEADER_PREFIX}/ }
|
109
119
|
end
|
data/lib/slimmer/headers.rb
CHANGED
@@ -20,6 +20,7 @@ module Slimmer
|
|
20
20
|
skip: "Skip",
|
21
21
|
template: "Template",
|
22
22
|
remove_search: "Remove-Search",
|
23
|
+
ignore_error: "Ignore-Error",
|
23
24
|
}.freeze
|
24
25
|
|
25
26
|
# @private
|
@@ -55,10 +56,15 @@ module Slimmer
|
|
55
56
|
# @private
|
56
57
|
REMOVE_SEARCH_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:remove_search]}".freeze
|
57
58
|
|
59
|
+
# @private
|
60
|
+
IGNORE_ERROR_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:ignore_error]}".freeze
|
61
|
+
|
62
|
+
|
58
63
|
# Set the "slimmer headers" to configure the page
|
59
64
|
#
|
60
65
|
# @param hash [Hash] the options
|
61
66
|
# @option hash [String] application_name
|
67
|
+
# @option hash [String] ignore_error
|
62
68
|
# @option hash [String] format
|
63
69
|
# @option hash [String] organisations
|
64
70
|
# @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.3.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-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|