Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8490477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:07:55+00:00 2026-06-10T22:07:55+00:00

I have the following code: $r->find(‘user’)->via(‘post’)->over(authenticated => 1); Given that route I can get

  • 0

I have the following code:

$r->find('user')->via('post')->over(authenticated => 1);

Given that route I can get to the user route passing through the authenticated check
that is setup using Mojolicious::Plugin::Authentication.

I want add another ‘over’ to that route.

$r->find('user')->via('post')->over(authenticated => 1)->over(access => 1);

That appears to override authenticated ‘over’ though.

I tried breaking up the routes with names like:

 my $auth = $r->route('/')->over(authenticated => 1)
     ->name('Authenticated Route');

 $access = $auth->route('/user')->over(access => 1)->name('USER_ACCESS');

That didn’t work at all though. Neither of the ‘over’s are being accessed.

My routes are things like /user, /item, set up using MojoX::JSON::RPC::Service.
So, I don’t have things like /user/:id to set up sub routes.( not sure that matters )
All routes are like /user, sent with parameters.

I’ve got a condition like:

$r->add_condition(
    access => sub {
        # do some stuff
    },
);

that is the ‘access’ in $r->route(‘/user’)->over(access => 1);

In short, the routes work fine when using:

$r->find('user')->via('post')->over(authenticated => 1);

But I’m unable to add a 2nd route.

So, what am I missing in setting up these routes with multiple conditions?
Is it possible to add multiple conditions to a single route /route_name?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:07:58+00:00Added an answer on June 10, 2026 at 10:07 pm

    You can just use both conditions in over like in this test:

    use Mojolicious::Lite;
    
    # dummy conditions storing their name and argument in the stash
    for my $name (qw(foo bar)) {
        app->routes->add_condition($name => sub {
            my ($route, $controller, $to, @args) = @_;
            $controller->stash($name => $args[0]);
        });
    }
    
    # simple foo and bar dump action
    sub dump {
        my $self = shift;
        $self->render_text(join ' ' => map {$self->stash($_)} qw(foo bar));
    }
    
    # traditional route with multiple 'over'
    app->routes->get('/frst')->over(foo => 'yo', bar => 'works')->to(cb => \&dump);
    
    # lite route with multiple 'over'
    get '/scnd' => (foo => 'hey', bar => 'cool') => \&dump;
    
    # test the lite app above
    use Test::More tests => 4;
    use Test::Mojo;
    
    my $t = Test::Mojo->new;
    
    # test first route
    $t->get_ok('/frst')->content_is('yo works');
    $t->get_ok('/scnd')->content_is('hey cool');
    
    __END__
    1..4
    ok 1 - get /frst
    ok 2 - exact match for content
    ok 3 - get /scnd
    ok 4 - exact match for content
    

    Works fine here with Mojolicious 3.38 on perl 5.12.1 – @DavidO is right, maybe bridges can do the job better. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code is supposed to find electors that do not have a postal
I have the following code that is trying to find a link that matches
I have the following find code: if($this->User->find('first', array( 'conditions' => array( 'User.username' => $this->data['User']['username'],
I have the following code snippet that is working find but am trying to
Please have a look at the following code: $(#saveButton).click(function(){ $this = $(#tableData).find(input:checked).parent().parent(); tea =
I have been trying to find out why the following lines of code do
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { using
I have this following code: $(.preview).find(#panel).each(function(i, val) { var x = + $(val).html(); $(x).find(.dmPageHeadline).prepend(
I have written the following code to find out the missing sequence but i
Have a look at the following code to find X^y. /* Find exponent in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.