Class: HttpRouter

Inherits:
Object
  • Object
show all
Defined in:
lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/routing.rb

Overview

HttpRouter adapter

Defined Under Namespace

Classes: Request, Route

Instance Method Summary collapse

Instance Method Details

#process_destination_path(path, env) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/routing.rb', line 27

def process_destination_path(path, env)
  Thread.current['padrino.instance'].instance_eval do
    request.route_obj = path.route
    @_response_buffer = nil
    @route    = path.route
    @params ||= {}
    @params.update(env['router.params'])
    @block_params = if match_data = env['router.request'].extra_env['router.regex_match']
      params_list = match_data.to_a
      params_list.shift
      @params[:captures] = params_list
      params_list
    else
      env['router.request'].params
    end
    # Provide access to the current controller to the request
    # Now we can eval route, but because we have "throw halt" we need to be
    # (en)sure to reset old layout and run controller after filters.
    original_params = @params
    parent_layout   = @layout
    successful      = false
    begin
      filter! :before
      (@route.before_filters - settings.filters[:before]).each { |block| instance_eval(&block) }
      @layout = path.route.use_layout if path.route.use_layout
      @route.custom_conditions.each { |block| pass if block.bind(self).call == false } if @route.custom_conditions
      halt_response     = catch(:halt) { route_eval { @route.dest[self, @block_params] } }
      @_response_buffer = halt_response.is_a?(Array) ? halt_response.last : halt_response
      successful        = true
      halt halt_response
    ensure
      (@route.after_filters - settings.filters[:after]).each { |block| instance_eval(&block) } if successful
      @layout = parent_layout
      @params = original_params
    end
  end
end

#rewrite_partial_path_info(env, request) ⇒ Object



24
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/routing.rb', line 24

def rewrite_partial_path_info(env, request); end

#rewrite_path_info(env, request) ⇒ Object



25
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/routing.rb', line 25

def rewrite_path_info(env, request); end