Answering my own question for posterity.  The following code works as a 
replacement:

helper get_any_arg_types_into_hash => sub  {
  my $self              = shift;
  my $names             = $self->req->params->names;
  my $content;

  if (defined($names)) {
    foreach my $p (@{$names}) {
      $content->{$p} = $self->param($p);
    }
  }
  return $content;
};


On Monday, January 23, 2017 at 1:50:50 PM UTC-5, Joe Landman wrote:
>
> Hi folks: 
>
>    I had written a Mojolicious::Lite app a few years ago, which had a 
> helper section like this: 
>
> #!/opt/scalable/bin/perl 
>
> use lib "lib/"; 
> use strict; 
> use v5.14; 
> use Mojolicious::Lite; 
>
> [...] 
>
> helper get_any_arg_types_into_hash => sub  { 
>    my $self              = shift; 
>    my @params            = $self->param; 
>    my $content; 
>
>    # copy parameters into content hash 
>    if (@params) { 
>      foreach my $p (@params) { 
>        $content->{$p} = $self->param($p); 
>      } 
>     } 
>    return $content; 
> }; 
>
> # then we use them in various of the controller endpoints 
>
>
> post '/contact' => sub { 
>    my $self = shift; 
>    my $content; 
>
>    $content = $self->get_any_arg_types_into_hash; 
>
> # ... 
>
> } 
>
> So this doesn't seem to work anymore in Mojolicious 7. Specifically, the 
> $self->params didn't seem to return an array of the keys of parameters. 
> Could be pilot error, but I simply copied the app from another machine 
> it is working on. 
>
> [root@facade ~]# /opt/scalable/bin/mojo version 
> CORE 
>    Perl        (v5.18.2, linux) 
>    Mojolicious (5.71, Tiger Face) 
>
> OPTIONAL 
>    EV 4.0+                 (n/a) 
>    IO::Socket::Socks 0.64+ (n/a) 
>    IO::Socket::SSL 1.84+   (1.973) 
>    Net::DNS::Native 0.15+  (n/a) 
>
>
>   It was written around Mojolicious 4 time frame, and has been working 
> reliably for years.  But now, not so much. 
>
> I still want to copy my args (all of them) into a content hash.  The 
> wiki docs (http://mojolicious.org/perldoc/Mojolicious/Controller#param) 
> suggest that the parameter method has changed somewhat, and may be using 
> stash (http://mojolicious.org/perldoc/Mojolicious/Controller#stash) for 
> access depending upon a few things that I've not quite wrapped my head 
> around. 
>
> So ... the short version ... 
>
> How do I get keys that indicate all of the parameters passed in (not 
> just placeholders, but any ?key=value type things as well). 
>
> This is 
>
> root@newfacade:~# /opt/scalable/bin/mojo version 
> CORE 
>    Perl        (v5.22.1, linux) 
>    Mojolicious (7.20, Doughnut) 
>
> OPTIONAL 
>    EV 4.0+                 (n/a) 
>    IO::Socket::Socks 0.64+ (n/a) 
>    IO::Socket::SSL 1.94+   (2.043) 
>    Net::DNS::Native 0.15+  (n/a) 
>
>
> Thanks! 
>
>
>
> -- 
> Joe Landman 
> e: [email protected] <javascript:> 
> t: @hpcjoe 
> c: +1 734 612 4615 
> w: https://scalability.org 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to