stark-rack 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Rakefile +3 -1
- data/lib/stark/rack.rb +4 -3
- data/stark-rack.gemspec +7 -6
- data/test/test_rack.rb +29 -0
- metadata +6 -5
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -12,10 +12,12 @@ Hoe::RUBY_FLAGS.concat " -I#{stark_local_path}" if File.directory?(stark_local_p
|
|
12
12
|
Hoe.plugin :git
|
13
13
|
Hoe.plugin :gemspec
|
14
14
|
|
15
|
-
Hoe.spec 'stark-rack' do
|
15
|
+
Hoe.spec 'stark-rack' do |spec|
|
16
16
|
developer('Evan Phoenix', 'evan@phx.io')
|
17
17
|
dependency 'stark', '< 2.0.0'
|
18
18
|
dependency 'rack', '>= 1.5.0', :dev
|
19
|
+
|
20
|
+
spec.testlib = :testunit if spec.respond_to?(:testlib)
|
19
21
|
end
|
20
22
|
|
21
23
|
# vim: syntax=ruby
|
data/lib/stark/rack.rb
CHANGED
@@ -5,7 +5,7 @@ require 'stark/rack/verbose_protocol'
|
|
5
5
|
|
6
6
|
class Stark::Rack
|
7
7
|
|
8
|
-
VERSION = '1.0.
|
8
|
+
VERSION = '1.0.1'
|
9
9
|
|
10
10
|
FORMAT = %{when: %0.4f, client: "%s", path: "%s%s", type: "%s", name: "%s", seqid: %d, error: %s\n}
|
11
11
|
|
@@ -69,7 +69,7 @@ class Stark::Rack
|
|
69
69
|
processor.process protocol, protocol
|
70
70
|
end
|
71
71
|
|
72
|
-
[status_from_last_error, headers(env), [out.string]]
|
72
|
+
[status_from_last_error(env), headers(env), [out.string]]
|
73
73
|
end
|
74
74
|
|
75
75
|
def error_capture
|
@@ -81,9 +81,10 @@ class Stark::Rack
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
def status_from_last_error
|
84
|
+
def status_from_last_error(env)
|
85
85
|
return 200 if @last_error.nil? || @last_error.first == :success
|
86
86
|
x = @last_error.last[3]
|
87
|
+
env['rack.exception'] = x
|
87
88
|
case x.type
|
88
89
|
when Thrift::ApplicationException::UNKNOWN_METHOD
|
89
90
|
404
|
data/stark-rack.gemspec
CHANGED
@@ -2,16 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "stark-rack"
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Evan Phoenix"]
|
9
|
-
s.date = "2013-
|
9
|
+
s.date = "2013-08-20"
|
10
10
|
s.description = "Provides middleware for mounting Stark/Thrift services as Rack endpoints."
|
11
11
|
s.email = ["evan@phx.io"]
|
12
12
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
|
13
|
-
s.files = [".autotest", ".gemtest", "History.txt", "Manifest.txt", "README.txt", "Rakefile", "lib/stark/rack.rb", "lib/stark/rack/content_negotiation.rb", "lib/stark/rack/logging_processor.rb", "lib/stark/rack/metadata.rb", "lib/stark/rack/rest.rb", "stark-rack.gemspec", "test/calc-opt.rb", "test/calc.thrift", "test/config.ru", "test/gen-rb/calc.rb", "test/gen-rb/calc_constants.rb", "test/gen-rb/calc_types.rb", "test/helper.rb", "test/test_metadata.rb", "test/test_rack.rb", "test/test_rest.rb"]
|
13
|
+
s.files = [".autotest", ".gemtest", "History.txt", "Manifest.txt", "README.txt", "Rakefile", "lib/stark/rack.rb", "lib/stark/rack/content_negotiation.rb", "lib/stark/rack/logging_processor.rb", "lib/stark/rack/metadata.rb", "lib/stark/rack/rest.rb", "lib/stark/rack/verbose_protocol.rb", "stark-rack.gemspec", "test/calc-opt.rb", "test/calc.thrift", "test/config.ru", "test/gen-rb/calc.rb", "test/gen-rb/calc_constants.rb", "test/gen-rb/calc_types.rb", "test/helper.rb", "test/test_metadata.rb", "test/test_rack.rb", "test/test_rest.rb"]
|
14
14
|
s.homepage = "https://github.com/evanphx/stark-rack"
|
15
|
+
s.licenses = ["MIT"]
|
15
16
|
s.rdoc_options = ["--main", "README.txt"]
|
16
17
|
s.require_paths = ["lib"]
|
17
18
|
s.rubyforge_project = "stark-rack"
|
@@ -26,17 +27,17 @@ Gem::Specification.new do |s|
|
|
26
27
|
s.add_runtime_dependency(%q<stark>, ["< 2.0.0"])
|
27
28
|
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
|
28
29
|
s.add_development_dependency(%q<rack>, [">= 1.5.0"])
|
29
|
-
s.add_development_dependency(%q<hoe>, ["~> 3.
|
30
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.7"])
|
30
31
|
else
|
31
32
|
s.add_dependency(%q<stark>, ["< 2.0.0"])
|
32
33
|
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
33
34
|
s.add_dependency(%q<rack>, [">= 1.5.0"])
|
34
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
35
|
+
s.add_dependency(%q<hoe>, ["~> 3.7"])
|
35
36
|
end
|
36
37
|
else
|
37
38
|
s.add_dependency(%q<stark>, ["< 2.0.0"])
|
38
39
|
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
39
40
|
s.add_dependency(%q<rack>, [">= 1.5.0"])
|
40
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
41
|
+
s.add_dependency(%q<hoe>, ["~> 3.7"])
|
41
42
|
end
|
42
43
|
end
|
data/test/test_rack.rb
CHANGED
@@ -62,4 +62,33 @@ class TestRack < Test::Unit::TestCase
|
|
62
62
|
assert_equal 404, code
|
63
63
|
end
|
64
64
|
|
65
|
+
def test_exception_sets_status_and_env_rack_exception
|
66
|
+
@client_p = Thrift::JsonProtocol.new @client_t
|
67
|
+
@client = @n::Calc::Client.new @client_p, @client_p
|
68
|
+
|
69
|
+
def @handler.add(*)
|
70
|
+
raise RangeError, "can't add"
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
code = headers = out = nil
|
75
|
+
env = { 'rack.input' => @sr, 'REQUEST_METHOD' => 'POST' }
|
76
|
+
env['PATH_INFO'] = ''
|
77
|
+
env['HTTP_CONTENT_TYPE'] = 'application/vnd.thrift+json'
|
78
|
+
|
79
|
+
st = Thread.new do
|
80
|
+
code, headers, out = stark_rack.call env
|
81
|
+
out.each do |s|
|
82
|
+
@sw << s
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
assert_raises Thrift::ApplicationException do
|
87
|
+
@client.add 3, 4
|
88
|
+
end
|
89
|
+
|
90
|
+
assert Thrift::ApplicationException === env['rack.exception']
|
91
|
+
assert env['rack.exception'].to_s =~ /^can't add/
|
92
|
+
end
|
93
|
+
|
65
94
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stark-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: stark
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '3.
|
69
|
+
version: '3.7'
|
70
70
|
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: '3.
|
77
|
+
version: '3.7'
|
78
78
|
description: Provides middleware for mounting Stark/Thrift services as Rack endpoints.
|
79
79
|
email:
|
80
80
|
- evan@phx.io
|
@@ -109,7 +109,8 @@ files:
|
|
109
109
|
- test/test_rack.rb
|
110
110
|
- test/test_rest.rb
|
111
111
|
homepage: https://github.com/evanphx/stark-rack
|
112
|
-
licenses:
|
112
|
+
licenses:
|
113
|
+
- MIT
|
113
114
|
post_install_message:
|
114
115
|
rdoc_options:
|
115
116
|
- --main
|