rack-app 5.0.0.rc1 → 5.0.0.rc2

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: 401d8f6ab979fa3f44891018a61dcf640d45b488
4
- data.tar.gz: 5d02724b737e668072d4ca5972d76d043cf854a5
3
+ metadata.gz: 4b130d9458099d27fab690cf3db1597ada7cac19
4
+ data.tar.gz: b05e1b11630efd3ced90361372634d121db73c25
5
5
  SHA512:
6
- metadata.gz: 010fcc827baf6f48e2ed0882a8d0b17052afc2dd11ae20659b722b91720f06a9bf161e4560d804b9f83b3e7c58c803cab8e1765719b6a312e45fd6479f7efcba
7
- data.tar.gz: ab3f8dec6d35b7c3ec9570d9af48a10d2ab9ff2e027755bd9dedded3648017ec5d5dd359d7becf3f4cd70688744b3164496328b190749fdfca91cd710956e13c
6
+ metadata.gz: d431d736219cce600153c1357dccb58742ac39babdaafadb3a0377954b55a56d5cca796e7c0dcc26dcfa105c4c21003c54b853a71bb3f78ef37e9983600fee3c
7
+ data.tar.gz: a8da83f4a90063bb491be7803615d05f795ccea24676700ba9b47073199730e4c6658a3868c59eb3b77508627a2db04e55ab25b45352a8b6280e62067acb2a70
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.0.0.rc1
1
+ 5.0.0.rc2
data/lib/rack/app.rb CHANGED
@@ -19,7 +19,6 @@ class Rack::App
19
19
  require 'rack/app/file_server'
20
20
  require 'rack/app/error_handler'
21
21
  require 'rack/app/bundled_extensions'
22
- require 'rack/app/endpoint/not_found'
23
22
  require 'rack/app/request_configurator'
24
23
 
25
24
  require 'rack/app/singleton_methods'
@@ -1,21 +1,34 @@
1
1
  module Rack::App::Constants
2
2
 
3
3
  module HTTP
4
- ANY = 'ANY'.freeze
5
- GET='GET'.freeze
6
- POST = 'POST'.freeze
7
- PUT = 'PUT'.freeze
8
- DELETE = 'DELETE'.freeze
9
- PATCH = 'PATCH'.freeze
10
- HEAD = 'HEAD'.freeze
11
- OPTIONS = 'OPTIONS'.freeze
4
+
5
+ module METHOD
6
+ ANY = 'ANY'.freeze
7
+ GET = 'GET'.freeze
8
+ POST = 'POST'.freeze
9
+ PUT = 'PUT'.freeze
10
+ PATCH = 'PATCH'.freeze
11
+ DELETE = 'DELETE'.freeze
12
+ HEAD = 'HEAD'.freeze
13
+ OPTIONS = 'OPTIONS'.freeze
14
+ LINK = 'LINK'.freeze
15
+ UNLINK = 'UNLINK'.freeze
16
+ TRACE = 'TRACE'.freeze
17
+ end
18
+
19
+ METHODS = (METHOD.constants - [:ANY]).map(&:to_s).freeze
20
+
21
+ end
22
+
23
+ module ENV
24
+ PARSED_PARAMS = 'rack-app.parsed_params'
25
+ VALIDATED_PARAMS = 'rack-app.validated_params'
26
+ ORIGINAL_PATH_INFO = 'rack-app.original_path_info'.freeze
27
+ PATH_PARAMS_MATCHER = 'rack-app.path_params_matcher'.freeze
28
+ METHODOVERRIDE_ORIGINAL_METHOD = 'rack-app.methodoverride.original_method'.freeze
12
29
  end
13
30
 
14
- ORIGINAL_PATH_INFO = 'rack-app.original_path_info'.freeze
15
- PATH_PARAMS_MATCHER = 'rack-app.path_params_matcher'.freeze
16
- RACK_BASED_APPLICATION = '[Mounted Rack Application]'.freeze
17
31
  MOUNTED_DIRECTORY = '[Mounted Directory]'.freeze
18
- VALIDATED_PARAMS = 'rack-app.validated_params'
19
- PARSED_PARAMS = 'rack-app.parsed_params'
20
-
32
+ RACK_BASED_APPLICATION = '[Mounted Rack Application]'.freeze
33
+
21
34
  end
@@ -1,25 +1,39 @@
1
+ require "rack/builder"
1
2
  class Rack::App::Endpoint
3
+ require "rack/app/endpoint/properties"
2
4
 
3
- attr_reader :properties
5
+ def properties
6
+ @properties.to_hash
7
+ end
4
8
 
5
9
  LAST_MODIFIED_HEADER = "Last-Modified".freeze
6
10
 
7
11
  def initialize(properties)
8
- @properties = properties
12
+ @properties = Rack::App::Endpoint::Properties.new(properties)
13
+ @endpoint_method_name = register_method_to_app_class(properties[:user_defined_logic])
14
+ end
9
15
 
10
- @app_class = properties[:app_class]
11
- @error_handler = properties[:error_handler] || Rack::App::ErrorHandler.new
12
- @serializer = properties[:serializer] || Rack::App::Serializer.new
16
+ def call(env)
17
+ to_app.call(env)
18
+ end
13
19
 
14
- middleware = (properties[:middleware] || Rack::Builder.new).dup
15
- middleware.run(lambda { |env| self.call_without_middlewares(env) })
16
- @endpoint_method_name = register_method_to_app_class(properties[:user_defined_logic])
20
+ def to_app
21
+ builder = Rack::Builder.new
22
+ apply_middleware_build_blocks(builder)
23
+ builder.run(lambda { |env| self.call_without_middlewares(env) })
24
+ builder.to_app
25
+ end
17
26
 
18
- @app = middleware.to_app
27
+ protected
28
+
29
+ def apply_middleware_build_blocks(builder)
30
+ builder_blocks.each do |builder_block|
31
+ builder_block.call(builder)
32
+ end
19
33
  end
20
34
 
21
- def call(env)
22
- @app.call(env)
35
+ def builder_blocks
36
+ @properties.app_class.middlewares + @properties.middleware_builders_blocks
23
37
  end
24
38
 
25
39
  def call_without_middlewares(env)
@@ -28,10 +42,8 @@ class Rack::App::Endpoint
28
42
  return catch(:rack_response){ execute(request, response) }.finish
29
43
  end
30
44
 
31
- protected
32
-
33
45
  def execute(request,response)
34
- request_handler = @app_class.new
46
+ request_handler = @properties.app_class.new
35
47
  request_handler.request = request
36
48
  request_handler.response = response
37
49
  set_response_body(response, get_response_body(request_handler))
@@ -41,24 +53,24 @@ class Rack::App::Endpoint
41
53
  def get_response_body(request_handler)
42
54
  catch :response_body do
43
55
  evaluated_value = evaluate_value(request_handler)
44
-
56
+
45
57
  evaluated_value
46
58
  end
47
59
  end
48
60
 
49
61
  def set_response_body(response, response_body)
50
- response.write(String(@serializer.serialize(response_body)))
62
+ response.write(String(@properties.serializer.serialize(response_body)))
51
63
  end
52
64
 
53
65
  def evaluate_value(request_handler)
54
- @error_handler.execute_with_error_handling_for(request_handler) do
66
+ @properties.error_handler.execute_with_error_handling_for(request_handler) do
55
67
  request_handler.__send__(@endpoint_method_name)
56
68
  end
57
69
  end
58
70
 
59
71
  def register_method_to_app_class(proc)
60
72
  method_name = '__' + ::Rack::App::Utils.uuid
61
- @app_class.__send__(:define_method, method_name, &proc)
73
+ @properties.app_class.__send__(:define_method, method_name, &proc)
62
74
  return method_name
63
75
  end
64
76
  end
@@ -0,0 +1,29 @@
1
+ class Rack::App::Endpoint::Properties
2
+
3
+ def to_hash
4
+ @raw
5
+ end
6
+
7
+ def app_class
8
+ @raw[:app_class] || raise('missing app class')
9
+ end
10
+
11
+ def serializer
12
+ @raw[:serializer] ||= Rack::App::Serializer.new
13
+ end
14
+
15
+ def error_handler
16
+ @raw[:error_handler] ||= Rack::App::ErrorHandler.new
17
+ end
18
+
19
+ def middleware_builders_blocks
20
+ @raw[:middleware_builders_blocks] ||= []
21
+ end
22
+
23
+ protected
24
+
25
+ def initialize(raw)
26
+ @raw = raw
27
+ end
28
+
29
+ end
@@ -3,11 +3,11 @@ module Rack::App::InstanceMethods::Core
3
3
  attr_writer :request, :response
4
4
 
5
5
  def params
6
- request.env[::Rack::App::Constants::PARSED_PARAMS] ||= Rack::App::Params.new(request.env).to_hash
6
+ request.env[::Rack::App::Constants::ENV::PARSED_PARAMS] ||= Rack::App::Params.new(request.env).to_hash
7
7
  end
8
8
 
9
9
  def validated_params
10
- request.env[::Rack::App::Constants::VALIDATED_PARAMS]
10
+ request.env[::Rack::App::Constants::ENV::VALIDATED_PARAMS]
11
11
  end
12
12
 
13
13
  def request
@@ -1,4 +1,5 @@
1
1
  module Rack::App::Middlewares
2
2
  require 'rack/app/middlewares/header_setter'
3
+ require 'rack/app/middlewares/method_override'
3
4
  require 'rack/app/middlewares/params'
4
5
  end
@@ -0,0 +1,55 @@
1
+ class Rack::App::Middlewares::MethodOverride
2
+
3
+ ALLOWED_METHODS = %w[GET POST].freeze
4
+ METHOD_OVERRIDE_PARAM_KEY = "_method".freeze
5
+ HTTP_METHOD_OVERRIDE_HEADER = "HTTP_X_HTTP_METHOD_OVERRIDE".freeze
6
+
7
+ def initialize(app)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ if affected_request?(env)
13
+ try_override(env)
14
+ end
15
+
16
+ @app.call(env)
17
+ end
18
+
19
+ protected
20
+
21
+ def try_override(env)
22
+ method = method_override(env)
23
+ if valid_https_method?(method)
24
+ set_request_method(method, env)
25
+ end
26
+ end
27
+
28
+ def set_request_method(method, env)
29
+ env[Rack::App::Constants::ENV::METHODOVERRIDE_ORIGINAL_METHOD] = env[Rack::REQUEST_METHOD]
30
+ env[Rack::REQUEST_METHOD] = method
31
+ end
32
+
33
+ def valid_https_method?(method)
34
+ Rack::App::Constants::HTTP::METHODS.include?(method)
35
+ end
36
+
37
+ def affected_request?(env)
38
+ ALLOWED_METHODS.include?(env[Rack::REQUEST_METHOD])
39
+ end
40
+
41
+ def method_override(env)
42
+ req = Rack::Request.new(env)
43
+ method = env[HTTP_METHOD_OVERRIDE_HEADER] ||
44
+ method_override_param(req,:POST) ||
45
+ method_override_param(req,:GET)
46
+
47
+ method.to_s.upcase
48
+ end
49
+
50
+ def method_override_param(req, http_method)
51
+ req.__send__(http_method)[METHOD_OVERRIDE_PARAM_KEY]
52
+ rescue Rack::Utils::InvalidParameterError, Rack::Utils::ParameterTypeError
53
+ end
54
+
55
+ end
@@ -16,7 +16,7 @@ class Rack::App::Middlewares::Params::Parser
16
16
 
17
17
  def set_params(env)
18
18
  params = Rack::App::Params.new(env).to_hash
19
- validated_params = (env[::Rack::App::Constants::VALIDATED_PARAMS] ||= {})
19
+ validated_params = (env[::Rack::App::Constants::ENV::VALIDATED_PARAMS] ||= {})
20
20
  parse_params(validated_params, params)
21
21
  end
22
22
 
@@ -5,7 +5,7 @@ class Rack::App::Middlewares::Params::Setter
5
5
  end
6
6
 
7
7
  def call(env)
8
- env[::Rack::App::Constants::PARSED_PARAMS] ||= params_hash(env)
8
+ env[::Rack::App::Constants::ENV::PARSED_PARAMS] ||= params_hash(env)
9
9
 
10
10
  @app.call(env)
11
11
  end
@@ -2,8 +2,8 @@ require 'cgi'
2
2
  class Rack::App::Params
3
3
 
4
4
  def to_hash
5
- if @request_env[::Rack::App::Constants::PARSED_PARAMS]
6
- @request_env[::Rack::App::Constants::PARSED_PARAMS]
5
+ if @request_env[::Rack::App::Constants::ENV::PARSED_PARAMS]
6
+ @request_env[::Rack::App::Constants::ENV::PARSED_PARAMS]
7
7
  else
8
8
  query_params.merge(request_path_params)
9
9
  end
@@ -58,7 +58,7 @@ class Rack::App::Params
58
58
  end
59
59
 
60
60
  def path_params_matcher
61
- @request_env[::Rack::App::Constants::PATH_PARAMS_MATCHER] || {}
61
+ @request_env[::Rack::App::Constants::ENV::PATH_PARAMS_MATCHER] || {}
62
62
  end
63
63
 
64
64
  end
@@ -11,7 +11,7 @@ module Rack::App::RequestConfigurator
11
11
 
12
12
  def path_info(env)
13
13
  path_info = env[::Rack::PATH_INFO]
14
- env[::Rack::App::Constants::ORIGINAL_PATH_INFO]= path_info
14
+ env[::Rack::App::Constants::ENV::ORIGINAL_PATH_INFO]= path_info
15
15
  env[::Rack::PATH_INFO]= Rack::App::Utils.normalize_path(path_info)
16
16
  end
17
17
 
@@ -51,6 +51,10 @@ class Rack::App::Router
51
51
  nil
52
52
  end
53
53
 
54
+ def reset
55
+ [@static, @dynamic].each(&:reset)
56
+ end
57
+
54
58
  protected
55
59
 
56
60
  def initialize
@@ -6,10 +6,10 @@ class Rack::App::Router::Base
6
6
  path_info= env[Rack::PATH_INFO]
7
7
 
8
8
  context = fetch_context(request_method, path_info)
9
- return unless context.is_a?(Hash) and not context[:endpoint].nil?
9
+ return unless context.is_a?(Hash) and not context[:app].nil?
10
10
 
11
11
  format_env(context, env)
12
- context[:endpoint].call(env)
12
+ context[:app].call(env)
13
13
 
14
14
  end
15
15
 
@@ -34,14 +34,26 @@ class Rack::App::Router::Base
34
34
  return endpoint
35
35
  end
36
36
 
37
+ def reset
38
+ compile_registered_endpoints!
39
+ end
40
+
37
41
  protected
38
42
 
39
- def fetch_context(request_method, request_path)
43
+ def compile_registered_endpoints!
40
44
  raise('IMPLEMENTATION MISSING ERROR')
41
45
  end
42
46
 
43
- def compile_registered_endpoints!
47
+ def fetch_context(request_method, request_path)
44
48
  raise('IMPLEMENTATION MISSING ERROR')
45
49
  end
46
50
 
51
+ def as_app(endpoint_or_app)
52
+ if endpoint_or_app.respond_to?(:to_app)
53
+ endpoint_or_app.to_app
54
+ else
55
+ endpoint_or_app
56
+ end
57
+ end
58
+
47
59
  end
@@ -73,6 +73,7 @@ class Rack::App::Router::Dynamic < Rack::App::Router::Base
73
73
 
74
74
  end
75
75
 
76
+ current_cluster[:app]= as_app(endpoint)
76
77
  current_cluster[:endpoint]= endpoint
77
78
  if current_cluster[:endpoint].respond_to?(:register_path_params_matcher)
78
79
  current_cluster[:endpoint].register_path_params_matcher(path_params)
@@ -91,7 +92,7 @@ class Rack::App::Router::Dynamic < Rack::App::Router::Base
91
92
  end
92
93
 
93
94
  def clusters_for(request_method)
94
- if ::Rack::App::Constants::HTTP::ANY == request_method
95
+ if ::Rack::App::Constants::HTTP::METHOD::ANY == request_method
95
96
  supported_http_protocols.each do |cluster_type|
96
97
  yield(main_cluster(cluster_type))
97
98
  end
@@ -101,7 +102,7 @@ class Rack::App::Router::Dynamic < Rack::App::Router::Base
101
102
  end
102
103
 
103
104
  def supported_http_protocols
104
- (::Rack::App::Constants::HTTP.constants - [:ANY]).map(&:to_s)
105
+ ::Rack::App::Constants::HTTP::METHODS
105
106
  end
106
107
 
107
108
 
@@ -111,7 +112,6 @@ class Rack::App::Router::Dynamic < Rack::App::Router::Base
111
112
  last_mounted_directory = nil
112
113
  last_mounted_app = nil
113
114
  current_cluster = main_cluster(request_method)
114
-
115
115
  normalized_request_path.split('/').each do |path_part|
116
116
 
117
117
  last_mounted_directory = current_cluster[MOUNTED_DIRECTORY] || last_mounted_directory
@@ -145,8 +145,8 @@ class Rack::App::Router::Dynamic < Rack::App::Router::Base
145
145
 
146
146
  def format_env(context, env)
147
147
  mount_path = context[:options][:mount_path] rescue ''
148
- env[::Rack::App::Constants::PATH_PARAMS_MATCHER]= context[:options][:path_params].dup
148
+ env[::Rack::App::Constants::ENV::PATH_PARAMS_MATCHER]= context[:options][:path_params].dup
149
149
  env[::Rack::PATH_INFO].sub!(mount_path, '')
150
150
  end
151
151
 
152
- end
152
+ end
@@ -1,11 +1,23 @@
1
+ require "rack/response"
1
2
  class Rack::App::Router::NotFound < Rack::App::Router::Base
2
3
 
3
4
  def fetch_context(request_method, path_info)
4
- {:endpoint => ::Rack::App::Endpoint::NOT_FOUND}
5
+ {:app => lambda{|env| not_found_response }}
5
6
  end
6
7
 
7
8
  def fetch_endpoint(request_method, path_info)
8
9
  ::Rack::App::Endpoint::NOT_FOUND
9
10
  end
10
11
 
11
- end
12
+ protected
13
+
14
+ def not_found_response
15
+ rack_response = Rack::Response.new
16
+ rack_response.status = 404
17
+ rack_response.write('404 Not Found')
18
+ rack_response.finish
19
+ end
20
+
21
+ def compile_registered_endpoints!
22
+ end
23
+ end
@@ -1,22 +1,21 @@
1
1
  class Rack::App::Router::Static < Rack::App::Router::Base
2
2
 
3
- def compile_registered_endpoints!
4
- mapped_endpoint_routes.clear
5
- endpoints.each do |endpoint|
6
- request_method, request_path, endpoint_object = endpoint[:request_method], endpoint[:request_path], endpoint[:endpoint]
7
- mapped_endpoint_routes[[request_method.to_s.upcase, request_path]]= endpoint_object
8
- end
9
- end
10
-
11
3
  protected
12
4
 
13
5
  def fetch_context(request_method, request_path)
14
- endpoint = mapped_endpoint_routes[[request_method, request_path]]
15
- endpoint && {:endpoint => endpoint}
6
+ app = mapped_endpoint_routes[[request_method, request_path]]
7
+ app && {:app => app}
16
8
  end
17
9
 
18
10
  def mapped_endpoint_routes
19
11
  @mapped_endpoint_routes ||= {}
20
12
  end
21
13
 
22
- end
14
+ def compile_registered_endpoints!
15
+ mapped_endpoint_routes.clear
16
+ endpoints.each do |endpoint|
17
+ app = as_app(endpoint[:endpoint])
18
+ mapped_endpoint_routes[[endpoint[:request_method].to_s.upcase, endpoint[:request_path]]]= app
19
+ end
20
+ end
21
+ end
@@ -3,31 +3,43 @@ module Rack::App::SingletonMethods::HttpMethods
3
3
  protected
4
4
 
5
5
  def get(path = '/', &block)
6
- add_route(::Rack::App::Constants::HTTP::GET, path, &block)
6
+ add_route(::Rack::App::Constants::HTTP::METHOD::GET, path, &block)
7
7
  end
8
8
 
9
9
  def post(path = '/', &block)
10
- add_route(::Rack::App::Constants::HTTP::POST, path, &block)
10
+ add_route(::Rack::App::Constants::HTTP::METHOD::POST, path, &block)
11
11
  end
12
12
 
13
13
  def put(path = '/', &block)
14
- add_route(::Rack::App::Constants::HTTP::PUT, path, &block)
14
+ add_route(::Rack::App::Constants::HTTP::METHOD::PUT, path, &block)
15
15
  end
16
16
 
17
17
  def delete(path = '/', &block)
18
- add_route(::Rack::App::Constants::HTTP::DELETE, path, &block)
18
+ add_route(::Rack::App::Constants::HTTP::METHOD::DELETE, path, &block)
19
19
  end
20
20
 
21
21
  def head(path = '/', &block)
22
- add_route(::Rack::App::Constants::HTTP::HEAD, path, &block)
22
+ add_route(::Rack::App::Constants::HTTP::METHOD::HEAD, path, &block)
23
23
  end
24
24
 
25
25
  def options(path = '/', &block)
26
- add_route(::Rack::App::Constants::HTTP::OPTIONS, path, &block)
26
+ add_route(::Rack::App::Constants::HTTP::METHOD::OPTIONS, path, &block)
27
27
  end
28
28
 
29
29
  def patch(path = '/', &block)
30
- add_route(::Rack::App::Constants::HTTP::PATCH, path, &block)
30
+ add_route(::Rack::App::Constants::HTTP::METHOD::PATCH, path, &block)
31
+ end
32
+
33
+ def link(path = '/', &block)
34
+ add_route(::Rack::App::Constants::HTTP::METHOD::LINK, path, &block)
35
+ end
36
+
37
+ def unlink(path = '/', &block)
38
+ add_route(::Rack::App::Constants::HTTP::METHOD::UNLINK, path, &block)
39
+ end
40
+
41
+ def trace(path = '/', &block)
42
+ add_route(::Rack::App::Constants::HTTP::METHOD::TRACE, path, &block)
31
43
  end
32
44
 
33
45
  def alias_endpoint(new_request_path, original_request_path)
@@ -1,10 +1,11 @@
1
1
  module Rack::App::SingletonMethods::Middleware
2
2
 
3
- protected
4
-
5
3
  def middlewares(&block)
6
4
  @middlewares ||= []
7
- @middlewares << block unless block.nil?
5
+ unless block.nil?
6
+ @middlewares << block
7
+ router.reset
8
+ end
8
9
  @middlewares
9
10
  end
10
11
 
@@ -14,6 +15,8 @@ module Rack::App::SingletonMethods::Middleware
14
15
  middlewares{ |b| b.use(*args) }
15
16
  end
16
17
 
18
+ protected
19
+
17
20
  def only_next_endpoint_middlewares(&block)
18
21
  @only_next_endpoint_middlewares ||= []
19
22
  @only_next_endpoint_middlewares << block unless block.nil?
@@ -40,18 +40,15 @@ module Rack::App::SingletonMethods::Mounting
40
40
  file_server = Rack::App::FileServer.new(Rack::App::Utils.expand_path(file_path))
41
41
  request_path = Rack::App::Utils.join(@namespaces, options[:to], '**', '*')
42
42
  router.register_endpoint!('GET', request_path, file_server, route_registration_properties)
43
- @last_description = nil
44
43
  end
45
44
 
46
45
  def mount_rack_based_application(rack_based_app, options={})
47
46
  router.register_endpoint!(
48
- ::Rack::App::Constants::HTTP::ANY,
47
+ ::Rack::App::Constants::HTTP::METHOD::ANY,
49
48
  Rack::App::Utils.join(@namespaces, options[:to], ::Rack::App::Constants::RACK_BASED_APPLICATION),
50
49
  rack_based_app,
51
50
  route_registration_properties
52
51
  )
53
-
54
- @last_description = nil
55
52
  end
56
53
 
57
54
  alias mount_app mount_rack_based_application
@@ -24,30 +24,21 @@ module Rack::App::SingletonMethods::RouteHandling
24
24
 
25
25
  request_path = ::Rack::App::Utils.join(@namespaces, request_path)
26
26
 
27
- builder = Rack::Builder.new
28
- (middlewares + only_next_endpoint_middlewares).each do |builder_block|
29
- builder_block.call(builder)
30
- end
31
-
32
- only_next_endpoint_middlewares.clear
33
-
34
27
  properties = {
35
28
  :user_defined_logic => block,
36
29
  :request_method => request_method,
37
30
  :request_path => request_path,
38
-
39
31
  :error_handler => error,
40
32
  :serializer => serializer,
41
- :middleware => builder,
33
+ :middleware_builders_blocks => only_next_endpoint_middlewares.dup,
42
34
  :app_class => self
43
35
  }
44
36
 
37
+ only_next_endpoint_middlewares.clear
45
38
 
46
39
  endpoint = Rack::App::Endpoint.new(properties)
47
40
  router.register_endpoint!(request_method, request_path, endpoint, route_registration_properties)
48
-
49
41
  @route_registration_properties = nil
50
- @last_description = nil
51
42
  return endpoint
52
43
 
53
44
  end
@@ -57,8 +48,8 @@ module Rack::App::SingletonMethods::RouteHandling
57
48
  @namespaces ||= []
58
49
  @namespaces.push(request_path_namespace)
59
50
  yield
51
+ ensure
60
52
  @namespaces.pop
61
- nil
62
53
  end
63
54
 
64
55
  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: 5.0.0.rc1
4
+ version: 5.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-16 00:00:00.000000000 Z
11
+ date: 2016-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,6 +78,7 @@ files:
78
78
  - ".gitignore"
79
79
  - ".rspec"
80
80
  - ".rubocop.yml"
81
+ - ".ruby-version"
81
82
  - ".travis.yml"
82
83
  - CODE_OF_CONDUCT.md
83
84
  - CONTRIBUTING.md
@@ -105,7 +106,7 @@ files:
105
106
  - lib/rack/app/cli/runner.rb
106
107
  - lib/rack/app/constants.rb
107
108
  - lib/rack/app/endpoint.rb
108
- - lib/rack/app/endpoint/not_found.rb
109
+ - lib/rack/app/endpoint/properties.rb
109
110
  - lib/rack/app/error_handler.rb
110
111
  - lib/rack/app/extension.rb
111
112
  - lib/rack/app/file_server.rb
@@ -116,6 +117,7 @@ files:
116
117
  - lib/rack/app/instance_methods/serve_file.rb
117
118
  - lib/rack/app/middlewares.rb
118
119
  - lib/rack/app/middlewares/header_setter.rb
120
+ - lib/rack/app/middlewares/method_override.rb
119
121
  - lib/rack/app/middlewares/params.rb
120
122
  - lib/rack/app/middlewares/params/definition.rb
121
123
  - lib/rack/app/middlewares/params/definition/options.rb
@@ -1,13 +0,0 @@
1
- app_class = Class.new(Rack::App)
2
- not_found_properties = {
3
- :user_defined_logic => lambda {
4
- response.status= 404
5
- return '404 Not Found'
6
- },
7
- :request_method => 'GET',
8
- :request_path => '\404',
9
- :description => 'page not found',
10
- :app_class => app_class
11
- }
12
-
13
- Rack::App::Endpoint::NOT_FOUND = Rack::App::Endpoint.new(not_found_properties)