rack-app 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rack/app.rb +2 -2
- data/lib/rack/app/endpoint.rb +23 -18
- data/lib/rack/app/endpoint/not_found.rb +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9db5bf57a1cc7db597b8f23aee6228a8d82412ef
|
4
|
+
data.tar.gz: d815b86a8348006082e616e1feccc6a2f4a90d2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da155363a4645977acaa3c49a6d5f5689919618b5ba4a4b25307ff6a8fa1405f3b731605dbd6e152087fdc5ad0a187a7dab7a6bb83f3e7966deba18b360b504f
|
7
|
+
data.tar.gz: 31e97114d7a842b112eb98e1f4e66e149a9b4b8484d118b6087e9ee3c26c916450473ab6bd6c47ad0bf2f212a24487b23a436f217cd7a3a1cdd6079d7aa7ddf4
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.17.0
|
data/lib/rack/app.rb
CHANGED
@@ -64,11 +64,11 @@ class Rack::App
|
|
64
64
|
def root(endpoint_path)
|
65
65
|
options '/' do
|
66
66
|
endpoint = self.class.router.fetch_endpoint('OPTIONS', Rack::App::Utils.normalize_path(endpoint_path))
|
67
|
-
endpoint.
|
67
|
+
endpoint.get_response_body(request,response)
|
68
68
|
end
|
69
69
|
get '/' do
|
70
70
|
endpoint = self.class.router.fetch_endpoint('GET', Rack::App::Utils.normalize_path(endpoint_path))
|
71
|
-
endpoint.
|
71
|
+
endpoint.get_response_body(request,response)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
data/lib/rack/app/endpoint.rb
CHANGED
@@ -2,6 +2,8 @@ class Rack::App::Endpoint
|
|
2
2
|
|
3
3
|
attr_reader :properties
|
4
4
|
|
5
|
+
LAST_MODIFIED_HEADER = "Last-Modified".freeze
|
6
|
+
|
5
7
|
def initialize(properties)
|
6
8
|
@properties = properties
|
7
9
|
|
@@ -19,19 +21,20 @@ class Rack::App::Endpoint
|
|
19
21
|
request = Rack::Request.new(request_env)
|
20
22
|
response = Rack::Response.new
|
21
23
|
|
22
|
-
|
23
|
-
request_handler = @api_class.new
|
24
|
+
set_response_body(response, get_response_body(request, response))
|
24
25
|
|
25
|
-
|
26
|
-
request_handler.response = response
|
27
|
-
request.env['rack.app.path_params_matcher']= @path_params_matcher.dup
|
26
|
+
return response.finish
|
28
27
|
|
29
|
-
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
add_response_body_if_missing(call_return, response)
|
30
|
+
def get_response_body(rack_request, rack_response)
|
33
31
|
|
34
|
-
|
32
|
+
request_handler = @api_class.new
|
33
|
+
set_default_headers(rack_response)
|
34
|
+
request_handler.request = rack_request
|
35
|
+
request_handler.response = rack_response
|
36
|
+
rack_request.env['rack.app.path_params_matcher']= @path_params_matcher.dup
|
37
|
+
return @error_handler.execute_with_error_handling_for(request_handler, @endpoint_method_name)
|
35
38
|
|
36
39
|
end
|
37
40
|
|
@@ -41,18 +44,20 @@ class Rack::App::Endpoint
|
|
41
44
|
|
42
45
|
protected
|
43
46
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
+
def set_response_body(response, result)
|
48
|
+
if result.is_a?(::Rack::App::File::Streamer)
|
49
|
+
response.length += result.length
|
50
|
+
response.headers[LAST_MODIFIED_HEADER]= result.mtime
|
51
|
+
response.body = result
|
47
52
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
+
else
|
54
|
+
response.write(String(@serializer.serialize(result)))
|
55
|
+
|
56
|
+
end
|
57
|
+
nil
|
53
58
|
end
|
54
59
|
|
55
|
-
def
|
60
|
+
def set_default_headers(response)
|
56
61
|
@headers.each do |header, value|
|
57
62
|
response.header[header]=value
|
58
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-02-
|
12
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|