PerlDancer / PerlDancer/Dancer2
uri_for and uri_for_route not respecting prefix?
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 604
- Forks
- 288
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 5
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the request methods uri_for and uri_for_route, along with the forward and prefix entry points described in the examples. Reproduce the /info/delete case and the loss of uri_for_route after forwarding from /bar to /foo; done means the prefix is respected and uri_for_route remains available after forward.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- perl
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100