rack-app 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/VERSION +1 -1
- data/lib/rack/app.rb +32 -16
- data/lib/rack/app/endpoint.rb +1 -2
- data/lib/rack/app/file/server.rb +8 -4
- data/lib/rack/app/test.rb +1 -0
- data/lib/rack/app/utils.rb +4 -0
- 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: 16ea665e2afdada4efa387171cadf926a87aa993
|
4
|
+
data.tar.gz: 5fcae940c35142946c418d11a4c8f929c1c120b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2032686e3243cdd0927dc5846baccdcaaba46ad7d88b300068e60886776af4cbdee53b6bb3c07cbaeb7d68fcec2b2d3a4ca506b1e89038e58b934780ede386e
|
7
|
+
data.tar.gz: 6f06939247a4f3d1c53364703b8b07e77008822da3f6d05f78d965c97b88b15b01a1b50768401834e8fd2c08d5ae99cafcee875860af73f0337c2bc505bc8ac8
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[travis-link]: http://travis-ci.org/rack-app/rack-app
|
5
5
|
[travis-home]: http://travis-ci.org/
|
6
6
|
|
7
|
-

|
8
8
|
|
9
9
|
Your next favourite rack based micro framework that is totally addition free!
|
10
10
|
Have a cup of awesomeness with your performance designed framework!
|
@@ -40,6 +40,11 @@ Or install it yourself as:
|
|
40
40
|
|
41
41
|
$ gem install rack-app
|
42
42
|
|
43
|
+
|
44
|
+
## Is it Production ready?
|
45
|
+
|
46
|
+
Yes, in fact it's already powering heroku hosted micro-services.
|
47
|
+
|
43
48
|
## Usage
|
44
49
|
|
45
50
|
config.ru
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.18.0
|
data/lib/rack/app.rb
CHANGED
@@ -24,7 +24,7 @@ class Rack::App
|
|
24
24
|
endpoint = router.fetch_endpoint(
|
25
25
|
request_env['REQUEST_METHOD'],
|
26
26
|
request_env[Rack::App::Constants::NORMALIZED_REQUEST_PATH])
|
27
|
-
endpoint.
|
27
|
+
endpoint.call(request_env)
|
28
28
|
end
|
29
29
|
|
30
30
|
def description(*description_texts)
|
@@ -64,18 +64,18 @@ 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.get_response_body(request,response)
|
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.get_response_body(request,response)
|
71
|
+
endpoint.get_response_body(request, response)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
def error(*exception_classes
|
75
|
+
def error(*exception_classes, &block)
|
76
76
|
@error_handler ||= Rack::App::ErrorHandler.new
|
77
77
|
unless block.nil?
|
78
|
-
@error_handler.register_handler(exception_classes,block)
|
78
|
+
@error_handler.register_handler(exception_classes, block)
|
79
79
|
end
|
80
80
|
|
81
81
|
return @error_handler
|
@@ -87,18 +87,15 @@ class Rack::App
|
|
87
87
|
|
88
88
|
def add_route(request_method, request_path, &block)
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
:serializer => serializer,
|
98
|
-
:app_class => self
|
99
|
-
}
|
90
|
+
properties = endpoint_properties.merge(
|
91
|
+
{
|
92
|
+
:user_defined_logic => block,
|
93
|
+
:request_method => request_method,
|
94
|
+
:request_path => request_path,
|
95
|
+
}
|
96
|
+
)
|
100
97
|
|
101
|
-
endpoint = Rack::App::Endpoint.new(
|
98
|
+
endpoint = Rack::App::Endpoint.new(properties)
|
102
99
|
router.add_endpoint(request_method, request_path, endpoint)
|
103
100
|
|
104
101
|
@last_description = nil
|
@@ -106,6 +103,13 @@ class Rack::App
|
|
106
103
|
|
107
104
|
end
|
108
105
|
|
106
|
+
def serve_files_from(relative_path, options={})
|
107
|
+
options.merge!(endpoint_properties)
|
108
|
+
file_server = Rack::App::File::Server.new(relative_path, options)
|
109
|
+
request_path = Rack::App::Utils.join(file_server.namespace, '**', '*')
|
110
|
+
router.add_endpoint('GET', request_path, file_server)
|
111
|
+
end
|
112
|
+
|
109
113
|
def mount(api_class)
|
110
114
|
|
111
115
|
unless api_class.is_a?(Class) and api_class <= Rack::App
|
@@ -133,6 +137,18 @@ class Rack::App
|
|
133
137
|
@headers
|
134
138
|
end
|
135
139
|
|
140
|
+
protected
|
141
|
+
|
142
|
+
def endpoint_properties
|
143
|
+
{
|
144
|
+
:default_headers => headers,
|
145
|
+
:error_handler => error,
|
146
|
+
:description => @last_description,
|
147
|
+
:serializer => serializer,
|
148
|
+
:app_class => self
|
149
|
+
}
|
150
|
+
end
|
151
|
+
|
136
152
|
end
|
137
153
|
|
138
154
|
def params
|
data/lib/rack/app/endpoint.rb
CHANGED
@@ -16,13 +16,12 @@ class Rack::App::Endpoint
|
|
16
16
|
@endpoint_method_name = register_method_to_app_class(properties[:user_defined_logic])
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def call(request_env)
|
20
20
|
|
21
21
|
request = Rack::Request.new(request_env)
|
22
22
|
response = Rack::Response.new
|
23
23
|
|
24
24
|
set_response_body(response, get_response_body(request, response))
|
25
|
-
|
26
25
|
return response.finish
|
27
26
|
|
28
27
|
end
|
data/lib/rack/app/file/server.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
class Rack::App::File::Server
|
2
2
|
|
3
|
+
attr_reader :namespace, :properties
|
4
|
+
|
3
5
|
def initialize(root_folder, options={})
|
4
6
|
require 'rack/file'
|
5
7
|
|
6
|
-
|
7
|
-
namespace.freeze
|
8
|
-
|
9
|
-
@namespace_rgx = /#{Regexp.escape(namespace)}/.freeze
|
8
|
+
@properties = options
|
9
|
+
@namespace = formatted_namespace(options).freeze
|
10
|
+
@namespace_rgx = /#{Regexp.escape(@namespace)}/.freeze
|
10
11
|
@rack_file_server = ::Rack::File.new(Rack::App::Utils.pwd(root_folder), {})
|
11
12
|
|
12
13
|
end
|
@@ -16,6 +17,9 @@ class Rack::App::File::Server
|
|
16
17
|
@rack_file_server.call(env)
|
17
18
|
end
|
18
19
|
|
20
|
+
def register_path_params_matcher(*args)
|
21
|
+
end
|
22
|
+
|
19
23
|
protected
|
20
24
|
|
21
25
|
def raw_namespace(options)
|
data/lib/rack/app/test.rb
CHANGED
@@ -66,6 +66,7 @@ module Rack::App::Test
|
|
66
66
|
"REQUEST_METHOD" => request_method.to_s.upcase,
|
67
67
|
"REQUEST_PATH" => url,
|
68
68
|
"REQUEST_URI" => url,
|
69
|
+
"PATH_INFO" => url,
|
69
70
|
"SERVER_PROTOCOL" => "HTTP/1.1",
|
70
71
|
"CONTENT_LENGTH" => "0",
|
71
72
|
"CONTENT_TYPE" => "application/x-www-form-urlencoded",
|
data/lib/rack/app/utils.rb
CHANGED
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.18.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-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|