Open SysPete opened 7 years ago
What about forwarded_from
with the original link? is_internal_forward
- do we have external forwards?
The question about naming is purely to make it clear that this is related to the use of the 'forward' keyword as opposed to the request having been forwarded to the app via a proxy.
If including the URL, it would be useful for this to be stored as an arrayref, as it's possible to have multiple forwards, and sometimes you will be interested in the original URL, while on other occasions, you will be interested in the immediately preceding URL.
Excellent point.
Very good idea indeed.
I'm now thinking that this might be a greater issue. If you think of forward
, you might have multiple forward
requests. you might want to track all of them. A pass
does something similar and you might want to track that as well. Two different keys? One key?
My proposal is to implement this cleanly using var
which exists for the particular purpose of retaining information between requests. Here's a native implementation:
get '/hello' => {
push @{ vars->{'previous_reqs'} }, request->path;
forward '/next';
};
This can also be wrapped in nicer syntax:
# This can be in a plugin
sub track {
push @{ vars->{'previous_reqs'} }, request->path;
return 1;
}
get '/hello' => sub {
track and forward '/';
};
Perhaps 'is_internal_forward'? Thoughts appreciated. Will sort a PR after #1246 is merged.