rack-blank 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/blank/version.rb +1 -1
- data/lib/rack/blank.rb +11 -10
- 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: 172dfe177707cf62db69c0d8045b527d451c8102
|
4
|
+
data.tar.gz: 3c19a4d4824ccb936efaf2636c71a56e56e53251
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c9a62bb818b9bc9dbd2e73506ba11502a5d4cca8dad3cf1deac2028d9d4479c3745a232532ba84723d2698ea47f0307e673629bfaa1619c6d529771d74fc41e
|
7
|
+
data.tar.gz: 738ca7911934c769d1283db5b82de1d57c9961bfa785787e2c168892fa1637b7495200adbca667a388ee50cbd70577f193cdf4152fa35af97b9be11231087b60
|
data/lib/rack/blank/version.rb
CHANGED
data/lib/rack/blank.rb
CHANGED
@@ -10,21 +10,22 @@ module Rack
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(env)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
request_path = "#{::File.dirname(env['PATH_INFO'])}/#{::File.basename(env['PATH_INFO'], '.*')}"
|
14
|
+
request_ext = ::File.extname(env['PATH_INFO'])
|
15
|
+
if request_path == @path
|
16
|
+
body = ''
|
17
|
+
content_type = 'text/plain'
|
18
|
+
if env['CONTENT_TYPE'] == 'application/json' || request_ext == '.json'
|
19
|
+
body = JSON.generate({})
|
20
|
+
content_type = 'application/json'
|
18
21
|
end
|
19
22
|
headers = {
|
20
23
|
"Content-Length" => body.bytesize.to_s,
|
21
|
-
"Content-Type" =>
|
24
|
+
"Content-Type" => content_type
|
22
25
|
}
|
23
|
-
|
24
|
-
return res
|
26
|
+
return [200, headers, [body]]
|
25
27
|
end
|
26
|
-
|
27
|
-
return res
|
28
|
+
return @app.call(env)
|
28
29
|
end
|
29
30
|
|
30
31
|
end
|