restfulie 1.0.0.beta5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/lib/restfulie/client/dsl.rb +1 -0
- data/lib/restfulie/client/feature/base_request.rb +16 -12
- data/lib/restfulie/client/feature/conneg_when_unaccepted.rb +1 -1
- data/lib/restfulie/client/feature/rescue_exception.rb +13 -0
- data/lib/restfulie/client/feature/retry_when_unavailable.rb +1 -1
- data/lib/restfulie/client/feature/throw_error.rb +1 -1
- metadata +12 -17
data/Rakefile
CHANGED
@@ -27,8 +27,8 @@ spec = Gem::Specification.new do |s|
|
|
27
27
|
s.add_dependency("json_pure", [">= 1.2.4"])
|
28
28
|
s.add_dependency("rack-conneg")
|
29
29
|
s.add_dependency("sqlite3-ruby")
|
30
|
-
s.add_dependency('tokamak', "
|
31
|
-
s.add_dependency('medie', "
|
30
|
+
s.add_dependency('tokamak', "~> 1.1.2")
|
31
|
+
s.add_dependency('medie', "~> 1.0.0")
|
32
32
|
s.add_dependency('respondie', "~> 0.9.0")
|
33
33
|
|
34
34
|
|
data/lib/restfulie/client/dsl.rb
CHANGED
@@ -11,25 +11,29 @@ class Restfulie::Client::Feature::BaseRequest
|
|
11
11
|
def request!(method, host, path, request, flow, env)
|
12
12
|
|
13
13
|
::Restfulie::Common::Logger.logger.info(request.http_to_s(method, path, [request.headers])) if ::Restfulie::Common::Logger.logger
|
14
|
-
|
15
|
-
http_request = get_connection_provider(host)
|
14
|
+
http_request = get_connection_provider(host)
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
rescue Exception => e
|
24
|
-
response = e
|
16
|
+
if env[:body]
|
17
|
+
enhance http_request.send(method, path, env[:body], request.headers)
|
18
|
+
else
|
19
|
+
enhance http_request.send(method, path, request.headers)
|
25
20
|
end
|
26
21
|
|
27
|
-
response
|
28
|
-
|
29
22
|
end
|
30
23
|
|
24
|
+
protected
|
25
|
+
|
31
26
|
def get_connection_provider(host)
|
32
27
|
@connection ||= ::Net::HTTP.new(host.host, host.port)
|
33
28
|
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def enhance(response)
|
33
|
+
def response.code
|
34
|
+
super.to_i
|
35
|
+
end
|
36
|
+
response
|
37
|
+
end
|
34
38
|
|
35
39
|
end
|
@@ -11,7 +11,7 @@ module Restfulie::Client::Feature
|
|
11
11
|
|
12
12
|
def execute(chain, request, env)
|
13
13
|
resp = chain.continue(request, env)
|
14
|
-
return resp if resp.code
|
14
|
+
return resp if resp.code!=406
|
15
15
|
|
16
16
|
accept = Medie.registry.for(resp.headers["Accept"])
|
17
17
|
return resp if accept.nil?
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Simple feature that returns the exception in case it occurs.
|
2
|
+
# This feature is automatically loaded in the stack.
|
3
|
+
class Restfulie::Client::Feature::RescueException
|
4
|
+
|
5
|
+
def execute(flow, request, env)
|
6
|
+
begin
|
7
|
+
flow.continue(request, env)
|
8
|
+
rescue Exception => e
|
9
|
+
e
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -9,7 +9,7 @@ class Restfulie::Client::Feature::ThrowError
|
|
9
9
|
Restfulie::Common::Logger.logger.error(result)
|
10
10
|
raise Restfulie::Client::HTTP::Error::ServerNotAvailableError.new(request, Restfulie::Client::HTTP::Response.new(request.verb, request.path, 503, nil, {}), result )
|
11
11
|
end
|
12
|
-
case result.response.code
|
12
|
+
case result.response.code
|
13
13
|
when 100..299
|
14
14
|
result
|
15
15
|
when 300..399
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restfulie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
|
11
|
-
- 5
|
12
|
-
version: 1.0.0.beta5
|
10
|
+
version: 1.0.0
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- Guilherme Silveira, Caue Guerra, Luis Cipriani, Everton Ribeiro, George Guimaraes, Paulo Ahagon, and many more!
|
@@ -40,16 +38,14 @@ dependencies:
|
|
40
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
40
|
requirements:
|
43
|
-
- -
|
41
|
+
- - ~>
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
43
|
+
hash: 23
|
46
44
|
segments:
|
47
45
|
- 1
|
48
|
-
-
|
49
|
-
-
|
50
|
-
|
51
|
-
- 4
|
52
|
-
version: 1.0.0.beta4
|
46
|
+
- 1
|
47
|
+
- 2
|
48
|
+
version: 1.1.2
|
53
49
|
type: :runtime
|
54
50
|
version_requirements: *id002
|
55
51
|
- !ruby/object:Gem::Dependency
|
@@ -58,16 +54,14 @@ dependencies:
|
|
58
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
59
55
|
none: false
|
60
56
|
requirements:
|
61
|
-
- -
|
57
|
+
- - ~>
|
62
58
|
- !ruby/object:Gem::Version
|
63
|
-
hash:
|
59
|
+
hash: 23
|
64
60
|
segments:
|
65
61
|
- 1
|
66
62
|
- 0
|
67
63
|
- 0
|
68
|
-
|
69
|
-
- 4
|
70
|
-
version: 1.0.0.beta4
|
64
|
+
version: 1.0.0
|
71
65
|
type: :runtime
|
72
66
|
version_requirements: *id003
|
73
67
|
- !ruby/object:Gem::Dependency
|
@@ -155,6 +149,7 @@ files:
|
|
155
149
|
- lib/restfulie/client/ext/open_search_ext.rb
|
156
150
|
- lib/restfulie/client/ext.rb
|
157
151
|
- lib/restfulie/client/feature/base.rb
|
152
|
+
- lib/restfulie/client/feature/rescue_exception.rb
|
158
153
|
- lib/restfulie/client/feature/base_request.rb
|
159
154
|
- lib/restfulie/client/feature/cache.rb
|
160
155
|
- lib/restfulie/client/feature/conneg_when_unaccepted.rb
|