Class: HttpRouter::Node::Path Private

Inherits:
HttpRouter::Node show all
Defined in:
lib/hanami/routing/http_router_monkey_patch.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#to_codeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/hanami/routing/http_router_monkey_patch.rb', line 12

def to_code
  path_ivar = inject_root_ivar(self)
  "#{"if !callback && request.path.size == 1 && request.path.first == '' && (request.rack_request.head? || request.rack_request.get?) && request.rack_request.path_info[-1] == ?/
    response = ::Rack::Response.new
    response.redirect(request.rack_request.path_info[0, request.rack_request.path_info.size - 1], 302)
    return response.finish
  end" if router.redirect_trailing_slash?}

  #{"if request.#{router.ignore_trailing_slash? ? 'path_finished?' : 'path.empty?'}" unless route.match_partially}
    if callback
      request.called = true
      callback.call(Response.new(request, #{path_ivar}))
    else
      env = request.rack_request.env
      env['router.request'] = request
      env['router.params'] ||= {}
      #{"env['router.params'].merge!(Hash[#{param_names.inspect}.zip(request.params)])" if dynamic?}
      @router.rewrite#{"_partial" if route.match_partially}_path_info(env, request)
      response = @router.process_destination_path(#{path_ivar}, env)
      return response unless router.pass_on_response(response)
    end
  #{"end" unless route.match_partially}"
end