rack-app 7.5.2 → 7.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE/bug_report.md +31 -0
- data/.ruby-version +1 -1
- data/.travis.yml +6 -8
- data/README.md +47 -27
- data/VERSION +1 -1
- data/assets/rack-app-logo.png +0 -0
- data/lib/rack/app/endpoint.rb +3 -0
- data/lib/rack/app/endpoint/catcher.rb +4 -1
- data/lib/rack/app/middlewares/params/validator.rb +8 -10
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 57ddda38e57ac78712e8664c0d8e2af239da7b5d136b2a935acd6eee770f57d1
|
4
|
+
data.tar.gz: f8bfb68ad081a9aee317c21d279f61cf79dbf94732c421b37ace1930975feb74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c77f424fc488bf6bd7291416ff45424aa0f6be582d51fc53c1fa0f9a743af66febc2af311dfb9d964723fdec70d910c9d198706ffc88726926f7fc389937309
|
7
|
+
data.tar.gz: 2d0a3d19c0a05471efc16ba29f9cfffa2df228cfb5a333905c258347bbd119650162115b9dc2db873ff771eb6a17a37a323843852bb138271a4b1a6169e23ce4
|
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to help us improve
|
4
|
+
title: ''
|
5
|
+
labels: bug
|
6
|
+
assignees: adamluzsi
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Describe the bug**
|
11
|
+
A clear and concise description of what the bug is.
|
12
|
+
|
13
|
+
**To Reproduce**
|
14
|
+
Steps to reproduce the behavior:
|
15
|
+
1. Go to '...'
|
16
|
+
2. Click on '....'
|
17
|
+
3. Scroll down to '....'
|
18
|
+
4. See error
|
19
|
+
|
20
|
+
**Expected behavior**
|
21
|
+
A clear and concise description of what you expected to happen.
|
22
|
+
|
23
|
+
**ruby interpreter**
|
24
|
+
ruby interpreter implementation like Mruby, Jruby, ...
|
25
|
+
|
26
|
+
**ruby version**
|
27
|
+
|
28
|
+
**rack-app version**
|
29
|
+
|
30
|
+
**Additional context**
|
31
|
+
Add any other context about the problem here.
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.3
|
data/.travis.yml
CHANGED
@@ -6,16 +6,14 @@ install:
|
|
6
6
|
- bundle install
|
7
7
|
|
8
8
|
rvm:
|
9
|
-
- 1.9
|
10
|
-
- 2.0.0
|
11
|
-
- 2.1.1
|
12
|
-
- 2.1.2
|
13
|
-
- 2.2.2
|
14
|
-
- 2.3.1
|
15
|
-
- jruby-19mode
|
16
|
-
|
17
9
|
- ruby-head
|
18
10
|
- jruby-head
|
11
|
+
- jruby-19mode
|
12
|
+
- 1.9
|
13
|
+
- 2.3.8
|
14
|
+
- 2.4.6
|
15
|
+
- 2.5.5
|
16
|
+
- 2.6.3
|
19
17
|
|
20
18
|
matrix:
|
21
19
|
allow_failures:
|
data/README.md
CHANGED
@@ -4,7 +4,9 @@
|
|
4
4
|
[travis-link]: https://travis-ci.org/rack-app/rack-app
|
5
5
|
[travis-home]: http://travis-ci.org/
|
6
6
|
|
7
|
-
|
7
|
+
![rack-app-logo](/assets/rack-app-logo.png)
|
8
|
+
|
9
|
+
Your next favorite rack-based micro-framework that is totally addition free!
|
8
10
|
Have a cup of awesomeness with your sadistically minimalist framework!
|
9
11
|
|
10
12
|
The idea behind is simple.
|
@@ -14,24 +16,42 @@ that will do nothing more than what you defined.
|
|
14
16
|
|
15
17
|
The Routing can handle any amount of endpoints that can fit in the memory,
|
16
18
|
so if you that crazy to use more than 10k endpoint,
|
17
|
-
you still
|
19
|
+
you still don't have to worry about response speed.
|
18
20
|
|
19
21
|
It was inspirited by sinatra, grape, and the pure use form of rack.
|
20
22
|
It's in production, powering Back Ends on Heroku
|
21
23
|
|
24
|
+
## Development Status
|
25
|
+
|
26
|
+
The framework considered stable.
|
27
|
+
I don't have the plan to feature creep the framework without real-life use-cases,
|
28
|
+
since most of the custom edge cases can be resolved with composition.
|
29
|
+
|
30
|
+
The next time it will receive further updates,
|
31
|
+
when rack provides a finalized support for http2.
|
32
|
+
|
33
|
+
If you have an issue, I weekly check the issues tab,
|
34
|
+
answer and reply, or implement a fix for it.
|
35
|
+
|
36
|
+
Since the framework, the only dependency is the `rack` gem,
|
37
|
+
I don't have to update the code base,
|
38
|
+
because there are no integration problems.
|
39
|
+
|
40
|
+
Cheers and Happy Coding!
|
41
|
+
|
22
42
|
## Concerns
|
23
43
|
|
24
|
-
If you want see fancy magic, you are in a bad place buddy!
|
44
|
+
If you want to see fancy magic, you are in a bad place buddy!
|
25
45
|
|
26
46
|
This also implies that the framework does not include extensions that monkey patch the whole world to give you nice features.
|
27
|
-
|
47
|
+
Clean architecture defines that a web framework should only provide an external interface to the web, and nothing more.
|
28
48
|
|
29
49
|
If you use rack-app, one thing is sure.
|
30
50
|
|
31
51
|
You either love it or will be able to remove it from the project even after years of development because,
|
32
52
|
it will not vendor-lock your application business entities and business use cases to this framework.
|
33
53
|
|
34
|
-
And it's
|
54
|
+
And it's totally fine for us. We don't want everyone to be tied to our solutions, we only want to build clean and well-designed software for the developer happiness.
|
35
55
|
|
36
56
|
## Installation
|
37
57
|
|
@@ -52,7 +72,7 @@ Or install it yourself as:
|
|
52
72
|
|
53
73
|
## Is it Production ready?
|
54
74
|
|
55
|
-
Yes,
|
75
|
+
Yes, it's already powering Heroku hosted micro-services.
|
56
76
|
|
57
77
|
## Principles
|
58
78
|
|
@@ -60,18 +80,18 @@ Yes, in fact it's already powering heroku hosted micro-services.
|
|
60
80
|
* No Code bloat
|
61
81
|
* No on run time processing, or keep at the bare minimum
|
62
82
|
* Fully BDD (Behaviour Driven Design)
|
63
|
-
*
|
83
|
+
* built-in test module to ease the development with easy to use tests
|
64
84
|
* Easy to Learn
|
65
85
|
* rack-app use well known and easy to understand conventions, such as sinatra like DSL
|
66
86
|
* Principle Of Least Surprise
|
67
87
|
* Modular design
|
68
|
-
* Only dependency is rack, nothing more
|
88
|
+
* the Only dependency is rack, nothing more
|
69
89
|
* Open development
|
70
|
-
* Try to create Examples for every feature
|
90
|
+
* Try to create Examples for every feature
|
71
91
|
|
72
92
|
## Features
|
73
93
|
|
74
|
-
*
|
94
|
+
* Easy to understand syntax
|
75
95
|
* module method level endpoint definition inspirited heavily by the Sinatra DSL
|
76
96
|
* unified error handling
|
77
97
|
* syntax sugar for default header definitions
|
@@ -80,18 +100,18 @@ Yes, in fact it's already powering heroku hosted micro-services.
|
|
80
100
|
* App mounting so you can create separated controllers for different task
|
81
101
|
* Streaming
|
82
102
|
* O(log(n)) lookup routing
|
83
|
-
* allows as many endpoint
|
84
|
-
* only basic sets for instance method
|
85
|
-
*
|
103
|
+
* allows as many endpoint registrations to you as you want, without impact on route lookup speed
|
104
|
+
* only basic sets for instance method level for the must need tools, such as params, payload
|
105
|
+
* Simple to use class level response serializer
|
86
106
|
* so you can choose what type of serialization you want without any enforced convention
|
87
|
-
* static file serving so you can mount even filesystem
|
88
|
-
* built
|
107
|
+
* static file serving so you can mount even filesystem-based endpoints too
|
108
|
+
* built-in testing module so your app can be easily written with BDD approach
|
89
109
|
* made with minimalism in mind so your app can't rely on the framework when you implement business logic
|
90
|
-
* if you need something, you should implement it without any dependency on a
|
110
|
+
* if you need something, you should implement it without any dependency on a web framework, rack-app only mean to be to provide you with easy to use interface to the web layer, nothing less and nothing more
|
91
111
|
* per endpoint middleware definitions
|
92
|
-
* you can define middleware stack before endpoints and it will only
|
93
|
-
* File Upload and file download
|
94
|
-
* note that this is not only memory friendly way pure rack solution, but also 2x faster than the
|
112
|
+
* you can define middleware stack before endpoints and it will only apply to them, similar like protected method workflow
|
113
|
+
* File Upload and file download efficiently and elegantly with minimal memory consuming
|
114
|
+
* note that this is not only memory friendly way pure rack solution, but also 2x faster than the usual solution which includes buffering in memory
|
95
115
|
* params validation with ease
|
96
116
|
|
97
117
|
## Under the hood
|
@@ -209,13 +229,13 @@ end
|
|
209
229
|
```
|
210
230
|
|
211
231
|
you can access Rack::Request with the request method and
|
212
|
-
Rack::Response as response method.
|
232
|
+
Rack::Response as a response method.
|
213
233
|
|
214
|
-
By default if you
|
234
|
+
By default, if you don't write anything to the response 'body' the endpoint block logic return will be used
|
215
235
|
|
216
236
|
### Frontend Example
|
217
237
|
|
218
|
-
if you don't mind
|
238
|
+
if you don't mind extending your dependency list then you can use the front_end extension for creating template-based web applications.
|
219
239
|
|
220
240
|
```ruby
|
221
241
|
require 'rack/app'
|
@@ -237,7 +257,7 @@ class App < Rack::App
|
|
237
257
|
layout 'layout.html.erb'
|
238
258
|
|
239
259
|
# at '/' the endpoint will serve (render)
|
240
|
-
# the ./app/index.html content as response body and wrap around with layout if layout is given
|
260
|
+
# the ./app/index.html content as response body and wrap around with layout if the layout is given
|
241
261
|
get '/' do
|
242
262
|
render 'index.html'
|
243
263
|
end
|
@@ -295,19 +315,19 @@ end
|
|
295
315
|
|
296
316
|
## Example Apps To start with
|
297
317
|
|
298
|
-
* [Official website How To examples](http://rack-app.com/)
|
318
|
+
* [Official website How To examples](http://www.rack-app.com/)
|
299
319
|
|
300
320
|
* [Rack::App Team Github repositories](https://github.com/rack-app)
|
301
321
|
|
302
322
|
* [Basic](https://github.com/rack-app/rack-app-example-basic)
|
303
|
-
* bare
|
323
|
+
* bare-bone simple example app
|
304
324
|
|
305
325
|
* [Escher Authorized Api](https://github.com/rack-app/rack-app-example-escher)
|
306
|
-
* complex authorization for corporal level
|
326
|
+
* complex authorization for corporal level API use
|
307
327
|
|
308
328
|
## [Benchmarking](https://github.com/rack-app/rack-app-benchmark)
|
309
329
|
|
310
|
-
This is a repo that used for measure Rack::App project speed in order keep an eye on the performance in every release.
|
330
|
+
This is a repo that used for measure Rack::App project speed in order to keep an eye on the performance in every release.
|
311
331
|
|
312
332
|
the benchmarking was taken on the following hardware specification:
|
313
333
|
* Processor: 2,7 GHz Intel Core i5
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.6.0
|
Binary file
|
data/lib/rack/app/endpoint.rb
CHANGED
@@ -28,6 +28,9 @@ class Rack::App::Endpoint
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def to_app
|
31
|
+
# TODO: fix this to cache it, but to that you need to resolve the problem when middlewares added,
|
32
|
+
# old endpoints are not refreshed by the middleware configs
|
33
|
+
# router.reset must be checked
|
31
34
|
self.class::Builder.new(@config).to_app
|
32
35
|
end
|
33
36
|
|
@@ -6,11 +6,14 @@ class Rack::App::Endpoint::Catcher
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def call(env)
|
9
|
-
handle_rack_response do
|
9
|
+
resp = handle_rack_response do
|
10
10
|
handle_response_body(env) do
|
11
11
|
@app.call(env)
|
12
12
|
end
|
13
13
|
end
|
14
|
+
return resp.finish if resp.is_a?(Rack::Response)
|
15
|
+
|
16
|
+
resp
|
14
17
|
end
|
15
18
|
|
16
19
|
protected
|
@@ -37,22 +37,20 @@ class Rack::App::Middlewares::Params::Validator
|
|
37
37
|
|
38
38
|
def validate_required_params(env, params)
|
39
39
|
@descriptor[:required].each do |key, properties|
|
40
|
-
validate_key(key,properties,params)
|
40
|
+
validate_key(key, properties, params)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def validate_optional_params(env, params)
|
45
45
|
@descriptor[:optional].each do |key, properties|
|
46
|
-
next unless params.
|
46
|
+
next unless params.key?(key)
|
47
47
|
|
48
|
-
validate_key(key,properties,params)
|
48
|
+
validate_key(key, properties, params)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def validate_key(key,properties,params)
|
53
|
-
unless params.
|
54
|
-
missing_key_error(key, properties[:class])
|
55
|
-
end
|
52
|
+
def validate_key(key, properties, params)
|
53
|
+
missing_key_error(key, properties[:class]) unless params.key?(key)
|
56
54
|
|
57
55
|
if properties[:of]
|
58
56
|
validate_array(properties[:class], properties[:of], key, *params[key])
|
@@ -69,7 +67,7 @@ class Rack::App::Middlewares::Params::Validator
|
|
69
67
|
end
|
70
68
|
|
71
69
|
def validate_array(type, elements_type, key, *elements)
|
72
|
-
values = elements.map{ |str| parse(elements_type, str) }
|
70
|
+
values = elements.map { |str| parse(elements_type, str) }
|
73
71
|
|
74
72
|
if values.include?(nil)
|
75
73
|
invalid_type_of_error(key, type, elements_type)
|
@@ -92,11 +90,11 @@ class Rack::App::Middlewares::Params::Validator
|
|
92
90
|
error "invalid key: #{key}"
|
93
91
|
end
|
94
92
|
|
95
|
-
def invalid_type_error(key,klass)
|
93
|
+
def invalid_type_error(key, klass)
|
96
94
|
error "invalid type for #{key}: #{klass} expected"
|
97
95
|
end
|
98
96
|
|
99
|
-
def invalid_type_of_error(key,klass,of)
|
97
|
+
def invalid_type_of_error(key, klass, of)
|
100
98
|
error "invalid type for #{key}: #{klass} of #{of} expected"
|
101
99
|
end
|
102
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,6 +75,7 @@ executables:
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
78
79
|
- ".gitignore"
|
79
80
|
- ".rspec"
|
80
81
|
- ".rubocop.yml"
|
@@ -89,6 +90,7 @@ files:
|
|
89
90
|
- VERSION
|
90
91
|
- Vagrantfile
|
91
92
|
- _config.yml
|
93
|
+
- assets/rack-app-logo.png
|
92
94
|
- bin/rack-app
|
93
95
|
- dev/console
|
94
96
|
- dev/rack-app
|
@@ -225,8 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
227
|
- !ruby/object:Gem::Version
|
226
228
|
version: '0'
|
227
229
|
requirements: []
|
228
|
-
|
229
|
-
rubygems_version: 2.6.8
|
230
|
+
rubygems_version: 3.0.3
|
230
231
|
signing_key:
|
231
232
|
specification_version: 4
|
232
233
|
summary: Your next favourite, performance designed micro framework!
|