Skip to content

uri_for and uri_for_route not respecting prefix? #1747

@cromedome

Description

@cromedome

See #1743

Given this:

prefix undef;
get '/edit' => sub { say request->uri_for('/search') }; # '/search'
prefix '/info';
get '/update' => sub { say request->uri_for('/delete') }; # /delete - should be '/info/delete'

If 'forwardis called, we generate an error:uri_for_route called on a request instance without it`

For this test case:

get '/foo' => sub { print Dumper request; 1 }
get '/bar' => sub { print Dumper request; forward '/foo' };

HTTP request for /bar prior to forward:

[...]
uri_for_route => sub {
      package Dancer2::Core::App;
      use warnings;
      use strict;
      shift();
      $weak_self->uri_for_route(@_);
  },

http request for /bar after forward to /foo:

uri_for_route => undef

This behaviour is alluded to in the docs "when forward is executed, the current dispatch of the route is aborted, the request is modified". Can this be changed so that uri_for_route is preserved?

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions