File tree 3 files changed +19
-13
lines changed 3 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ def self.deprecator
42
42
@deprecator ||= ActiveSupport ::Deprecation . new ( '2.0' , 'Grape' )
43
43
end
44
44
45
+ def self . rack3?
46
+ Gem ::Version . new ( ::Rack . release ) >= Gem ::Version . new ( '3' )
47
+ end
48
+
45
49
eager_autoload do
46
50
autoload :API
47
51
autoload :Endpoint
Original file line number Diff line number Diff line change @@ -11,22 +11,22 @@ module Headers
11
11
REQUEST_METHOD = 'REQUEST_METHOD'
12
12
QUERY_STRING = 'QUERY_STRING'
13
13
14
- if Gem ::Version . new ( Rack . release ) < Gem ::Version . new ( '3' )
15
- ALLOW = 'Allow'
16
- CACHE_CONTROL = 'Cache-Control'
17
- CONTENT_LENGTH = 'Content-Length'
18
- CONTENT_TYPE = 'Content-Type'
19
- LOCATION = 'Location'
20
- TRANSFER_ENCODING = 'Transfer-Encoding'
21
- X_CASCADE = 'X-Cascade'
22
- else
14
+ if Grape . rack3?
23
15
ALLOW = 'allow'
24
16
CACHE_CONTROL = 'cache-control'
25
17
CONTENT_LENGTH = 'content-length'
26
18
CONTENT_TYPE = 'content-type'
27
19
LOCATION = 'location'
28
20
TRANSFER_ENCODING = 'transfer-encoding'
29
21
X_CASCADE = 'x-cascade'
22
+ else
23
+ ALLOW = 'Allow'
24
+ CACHE_CONTROL = 'Cache-Control'
25
+ CONTENT_LENGTH = 'Content-Length'
26
+ CONTENT_TYPE = 'Content-Type'
27
+ LOCATION = 'Location'
28
+ TRANSFER_ENCODING = 'Transfer-Encoding'
29
+ X_CASCADE = 'X-Cascade'
30
30
end
31
31
32
32
GET = 'GET'
Original file line number Diff line number Diff line change @@ -46,12 +46,14 @@ def build_headers
46
46
end
47
47
end
48
48
49
- def transform_header ( header )
50
- if Gem ::Version . new ( Rack . release ) < Gem ::Version . new ( '3' )
51
- -header [ 5 ..] . split ( '_' ) . map ( &:capitalize ) . join ( '-' )
52
- else
49
+ if Grape . rack3?
50
+ def transform_header ( header )
53
51
-header [ 5 ..] . tr ( '_' , '-' ) . downcase
54
52
end
53
+ else
54
+ def transform_header ( header )
55
+ -header [ 5 ..] . split ( '_' ) . map ( &:capitalize ) . join ( '-' )
56
+ end
55
57
end
56
58
end
57
59
end
You can’t perform that action at this time.
0 commit comments