What is the hash key 'cb' in: $r->to->(cb=>sub{...})

21 views
Skip to first unread message

Randall Sindlinger

unread,
Aug 12, 2016, 3:08:09 PM8/12/16
to Mojolicious
Hi,

I'm working on code that I inherited, and I've hit something that is opaque to me.

What does this code snip in setup() intend to do, specifically regarding the hash key 'cb'?

      my $authed = $r->under("/$path_base")->to(cb => sub {
             
my $c = shift;
             
return $c->deny_auth unless $c->auth && $c->authz(role => 'update');
             
return 1;
         
})->name("authed_select_$name");
      $authed
->post->to("$cname#create")->name("create_$name");


The documentation on to() doesn't seem to help here.

I see some references to a $cb value in the bowels of the mojilicious code base, so I'm guessing it's reaching inside to affect behavour somewhere; furthermore, I don't see the hash key cb being used anywhere in the code; only being set during the app setup().

The full code context is at https://github.com/USGCRP/gcis/blob/master/lib/Tuba.pm#L259 , if that's helpful.

Thanks in advance for any insights,
-Randall


Dan Book

unread,
Aug 12, 2016, 4:29:15 PM8/12/16
to mojol...@googlegroups.com

--
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 mojolicious+unsubscribe@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages