I use bridges for authentication, like this:

    my $logged_in = $r->bridge->to(cb => sub {
        my $c = shift;
        return 1 if $c->stash('user');
        $c->redirect_to('/login');
        return undef;
    });

    $logged_in->route('/edit_profile')-> ...

This simplifies my routes and removes duplicate code in my actions.

I would also like to use bridges as a filter for AJAX requests, such as:

    my $is_xhr = $r->bridge->to(cb => sub {
        my $c = shift;
        return 1 if $c->req->is_xhr;
        return undef;
    });

    $is_xhr->route('/ajax_handler')-> ...

This would save me from having to put the following statement inside all of
my AJAX handlers:

    return $c->render_not_found unless $c->req->is_xhr;

I want to be able to be able to combine the two bridges, linking them 
together
somehow, so that the request has to pass through both $logged_in and 
$is_xhr,
before it will match with an action.

Is this possible?

-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to