@@ -27,28 +27,32 @@ def initialize(settings, options = {}, &block)
2727 end
2828
2929 def mount_in ( route_set )
30- options [ :method ] . each do |method |
31- options [ :path ] . each do |path |
32- prepared_path = prepare_path ( path )
33- path = compile_path ( path , !options [ :app ] )
34- regex = Rack ::Mount ::RegexpWithNamedGroups . new ( path )
35- path_params = regex . named_captures . map { |nc | nc [ 0 ] } - [ 'version' , 'format' ]
36- path_params |= ( options [ :route_options ] [ :params ] || [ ] )
37- request_method = ( method . to_s . upcase unless method == :any )
38-
39- # routes << Route.new(route_options.merge({
40- # :prefix => prefix,
41- # :version => settings[:version] ? settings[:version].join('|') : nil,
42- # :namespace => namespace,
43- # :method => request_method,
44- # :path => prepared_path,
45- # :params => path_params})
46- # )
47-
48- route_set . add_route ( self ,
49- :path_info => path ,
50- :request_method => request_method
51- )
30+ if options [ :app ] && options [ :app ] . respond_to? ( :endpoints )
31+ options [ :app ] . endpoints . each { |e | e . mount_in ( route_set ) }
32+ else
33+ options [ :method ] . each do |method |
34+ options [ :path ] . each do |path |
35+ prepared_path = prepare_path ( path )
36+ path = compile_path ( path , !options [ :app ] )
37+ regex = Rack ::Mount ::RegexpWithNamedGroups . new ( path )
38+ path_params = regex . named_captures . map { |nc | nc [ 0 ] } - [ 'version' , 'format' ]
39+ path_params |= ( options [ :route_options ] [ :params ] || [ ] )
40+ request_method = ( method . to_s . upcase unless method == :any )
41+
42+ # routes << Route.new(route_options.merge({
43+ # :prefix => prefix,
44+ # :version => settings[:version] ? settings[:version].join('|') : nil,
45+ # :namespace => namespace,
46+ # :method => request_method,
47+ # :path => prepared_path,
48+ # :params => path_params})
49+ # )
50+
51+ route_set . add_route ( self ,
52+ :path_info => path ,
53+ :request_method => request_method
54+ )
55+ end
5256 end
5357 end
5458 end
@@ -80,7 +84,6 @@ def call(env)
8084
8185 def call! ( env )
8286 if options [ :app ]
83- $stderr. puts env . inspect
8487 options [ :app ] . call ( env )
8588 else
8689 builder = build_middleware
0 commit comments