rack-app 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58f26a39292b8d52e2bfeabf12e5bdeb865cd9e4
4
- data.tar.gz: f1fa441f35fe56d10ede7e4731281210f8b5d352
3
+ metadata.gz: 32dc4d9b8547ea72c4dbedc26574c6f656e5964a
4
+ data.tar.gz: a1e719b055a7c201abbeb6cd0b9d7dc603ba966a
5
5
  SHA512:
6
- metadata.gz: 5fa94365b0a18d26dc3f666a38bafe6686227d68599dce43a1d941aaac736ec678831537ed5dd00f404c44f166c9eff17a43bb36633f79ea95ac70d39ee46980
7
- data.tar.gz: 462d5fca3c4429ccdc942159666539500850801cc571e6ad75db1ff73790952d20e46f42b9e2f1e0beecef5f6bb96e41e332f47797da1f88390a01fa386a40e9
6
+ metadata.gz: b177de5e0036bbc20ced07f3cbefc78ff49cd06d56ae3aad89235169aa972f9ae53906cfc7b89ea94ec14b4c2bea409d466ea288a03cb2af7037a301c4c5a50b
7
+ data.tar.gz: 308fed5ee5aff8145a6d8fc52d865e3e0df32dfe05001ec7df939869b4dee2f5239d8c34c4eeaa53957dc26d0aa9c0b4fa68ec2b78eec8bccfacef7e672290e6
data/README.md CHANGED
@@ -108,18 +108,24 @@ end
108
108
 
109
109
  ## [Benchmarking](https://github.com/adamluzsi/rack-app.rb-benchmark)
110
110
 
111
- * Dumb duration with zero if or routing: 5.0e-06 s - 6.0e-06 s
111
+
112
+ * Dump duration with zero business logic or routing: 2.4184169999892074e-06 s
112
113
  * no routing
113
114
  * return only a static array with static values
114
- * Rack::App duration with routing lookup: 6.3e-05 s - 7.0e-05 s
115
+ * Rack::App duration with routing lookup: 2.9978291999967683e-05 s
115
116
  * with routing
116
117
  * with value parsing and reponse object building
117
- * Grape::API duration with routing lookup: 0.028236 s - 0.180764 s
118
+ * Grape::API duration with routing lookup: 0.0002996424499999746 s
118
119
  * with routing
119
120
  * with value parsing and reponse object building
121
+
122
+ * Rack::App 9.995314276086763x faster (0.00026966415800000693 sec) that Grape::API
123
+ * returning a simple rack response array without any logic is 12.395832480544698x faster (2.7559874999978477e-05 sec) that Rack::App
124
+ * the same dumb empty proc call is 123.90024135676842x faster than Grape::API (0.0002972240329999854 sec)
120
125
 
121
126
  This was measured with multiple endpoints like that would be in real life example.
122
- i feared do this for Rails that is usually slower than Grape :S
127
+ I feared do this for Rails that is usually slower than Grape :S
128
+ To be honest, I measured with grape because that is one of my favorite micro framework
123
129
 
124
130
  ## Roadmap
125
131
 
@@ -127,22 +133,6 @@ i feared do this for Rails that is usually slower than Grape :S
127
133
 
128
134
  If you have anything to say, you can leave a comment. :)
129
135
 
130
- ### 0.10.0
131
-
132
- * serializer block/method for class shared serialization logic
133
- * Mount method should able to take namespace option
134
- * Create erb Parser Gem for View/FileServer to support to .erb files
135
-
136
- ### 0.11.0
137
-
138
- * content_type syntax sugar on class level
139
- * response_headers syntax sugar for request processing
140
-
141
- ### 0.12.0
142
-
143
- * custom error_handler block for api, where Exception class types can be defined to process
144
- * NULL Object pattern for error_handler_fetcher
145
-
146
136
  ## Development
147
137
 
148
138
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.0
1
+ 0.14.0
@@ -89,11 +89,12 @@ class Rack::App
89
89
 
90
90
  endpoint_properties = {
91
91
  :user_defined_logic => block,
92
+ :default_headers => headers,
92
93
  :request_method => request_method,
94
+ :error_handler => error,
93
95
  :request_path => request_path,
94
96
  :description => @last_description,
95
97
  :serializer => serializer,
96
- :error_handler => error,
97
98
  :app_class => self
98
99
  }
99
100
 
@@ -126,6 +127,12 @@ class Rack::App
126
127
  return @serializer
127
128
  end
128
129
 
130
+ def headers(new_headers=nil)
131
+ @headers ||= {}
132
+ @headers.merge!(new_headers) if new_headers.is_a?(Hash)
133
+ @headers
134
+ end
135
+
129
136
  end
130
137
 
131
138
  def params
@@ -4,10 +4,12 @@ class Rack::App::Endpoint
4
4
 
5
5
  def initialize(properties)
6
6
  @properties = properties
7
+
8
+ @error_handler = properties[:error_handler]
7
9
  @logic_block = properties[:user_defined_logic]
8
10
  @serializer = properties[:serializer]
9
11
  @api_class = properties[:app_class]
10
- @error_handler = properties[:error_handler]
12
+ @headers = properties[:default_headers]
11
13
 
12
14
  @path_params_matcher = {}
13
15
  end
@@ -18,6 +20,7 @@ class Rack::App::Endpoint
18
20
  request = Rack::Request.new(request_env)
19
21
  response = Rack::Response.new
20
22
 
23
+ add_default_headers(response)
21
24
  request_handler = @api_class.new
22
25
 
23
26
  request_handler.request = request
@@ -50,4 +53,10 @@ class Rack::App::Endpoint
50
53
  call_return[1].is_a?(Hash)
51
54
  end
52
55
 
56
+ def add_default_headers(response)
57
+ @headers.each do |header,value|
58
+ response.header[header]=value
59
+ end
60
+ end
61
+
53
62
  end
@@ -5,11 +5,12 @@ not_found_properties = {
5
5
  response.write '404 Not Found'
6
6
  response.finish
7
7
  },
8
+ :default_headers => {},
8
9
  :request_method => 'GET',
10
+ :error_handler => Rack::App::ErrorHandler.new,
9
11
  :request_path => '\404',
10
12
  :description => 'page not found',
11
13
  :serializer => Rack::App::Serializer.new,
12
- :error_handler => Rack::App::ErrorHandler.new,
13
14
  :app_class => app_class
14
15
  }
15
16
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.summary = %q{Your next favourite, performance designed micro framework!}
14
14
  spec.description = %q{Your next favourite rack based micro framework that is totally addition free! Have a cup of awesomeness with your to performance designed framework!}
15
- spec.homepage = 'https://github.com/adamluzsi/rack-app.rb'
15
+ spec.homepage = 'https://github.com/rack-app'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
18
  spec.bindir = "exe"
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.13.0
4
+ version: 0.14.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-06 00:00:00.000000000 Z
12
+ date: 2016-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -107,7 +107,7 @@ files:
107
107
  - lib/rack/app/version.rb
108
108
  - rack-app.gemspec
109
109
  - spike/routing_time.rb
110
- homepage: https://github.com/adamluzsi/rack-app.rb
110
+ homepage: https://github.com/rack-app
111
111
  licenses:
112
112
  - GNU General Public License v3
113
113
  metadata: {}