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 6546461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:42:38+00:00 2026-05-25T11:42:38+00:00

Is there a way to have one app in dancer but with multiple appdirs.

  • 0

Is there a way to have one app in dancer but with multiple appdirs.

Or could I do something like this:

My project is in dir ‘foo’. And let’s say that I have a dir ‘bar’ (not inside ‘foo’) which has a directory called ‘public’. I what my app ‘foo’ to use this public as its own public and if it searches for let’s say ‘/css/style.css’ and it is not in ‘/bar/public/’ it should search the ‘/foo/public/’. How can I do that?

  • 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-05-25T11:42:39+00:00Added an answer on May 25, 2026 at 11:42 am

    One of the ways if to write a plugin that renders static (and replaces some functionality). You can use Dancer::Plugin::Thumbnail as an example.

    Other way I see is to monkey-patch get_file_response() at Dancer::Renderer which is not really such a good idea.

    Following code looks for static files in each dir from @dirs array. It’s dirty, ugly and unsafe.
    This can be broken in future version and may cause problems with other parts of Dancer framework I’m not familiar with. You’re warned.

    #!/usr/bin/env perl
    use Dancer;
    use Dancer::Renderer;
    use MyWeb::App;
    
    my $get_file_response_original = \&Dancer::Renderer::get_file_response;
    my @dirs = ('foo');
    
    *Dancer::Renderer::get_file_response = sub {
        my $app = Dancer::App->current;
    
        my $result;
    
        # Try to find static in default dir
        if ($result = $get_file_response_original->(@_)) {
            return $result;
        }
    
        # Save current settings
        my $path_backup = $app->setting('public');
    
        # Go through additional dirs
        foreach my $dir (@dirs) {
            $app->setting(public => $dir);
            if ($result = $get_file_response_original->(@_)) {
                last;
            }
        }
    
        # Restore public
        $app->setting('public' => $path_backup);
    
        return $result
    };
    
    dance;
    

    Third ways is to let nginx just do this work for you by writing proper nginx config for your application.

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

Sidebar

Related Questions

Is there any way to have this: [one[two]][three] And extract this with a regex?
Is there any way to have something that looks just like a file on
Is there a way to have two different Java code for one Android app?
Is there a way to have the callback of one AJAX trigger another AJAX
In Team Foundation Server is there a way to have work items in one
Is there a way in Python, to have more than one constructor or more
Is there any way I can combine list of expressions into one? I have
I have one table view within the app that I hope multiple parts of
I have one .xib file with an App Delegate. In this App Delegate, I
Is there a way to make one as i have seen one on the

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.