Guest User

Untitled

a guest
Jun 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. Index: lib/Catalyst/Request.pm
  2. ===================================================================
  3. --- lib/Catalyst/Request.pm (revision 10738)
  4. +++ lib/Catalyst/Request.pm (working copy)
  5. @@ -571,6 +571,34 @@
  6.  
  7. Returns a URI object for the current request. Stringifies to the URI text.
  8.  
  9. +=head2 $req->uri_append( { key => 'value' } );
  10. +
  11. +Returns a rewritten URI object for the current request. Key/value pairs
  12. +passed in will be appended to existing parameters. You can remove an existing
  13. +parameter by passing in an undef value. Unmodified pairs will be preserved.
  14. +
  15. +Compare this to C<uri_with> which replaces existing parameters.
  16. +
  17. +=cut
  18. +
  19. +sub uri_append {
  20. + my ($self, $args) = @_;
  21. +
  22. + carp('No arguments passed to uri_append()') unless $args;
  23. +
  24. + my $uri = $self->uri->clone;
  25. + foreach my $key (keys %{ $args }) {
  26. + my $val = $args->{$key};
  27. + if(defined($val)) {
  28. + $uri->query_param_append($key, $val);
  29. + } else {
  30. + $uri->query_param_delete($key);
  31. + }
  32. + }
  33. +
  34. + return $uri;
  35. +}
  36. +
  37. =head2 $req->uri_with( { key => 'value' } );
  38.  
  39. Returns a rewritten URI object for the current request. Key/value pairs
  40. @@ -578,6 +606,8 @@
  41. parameter by passing in an undef value. Unmodified pairs will be
  42. preserved.
  43.  
  44. +Compare this to C<uri_append> which appends to existing parameters.
  45. +
  46. =cut
  47.  
  48. sub uri_with {
Add Comment
Please, Sign In to add comment