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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:22:36+00:00 2026-06-06T09:22:36+00:00

This I’m trying for transfer my current Apache/Modperl site to Starman, and need build

  • 0

This I’m trying for transfer my current Apache/Modperl site to Starman, and need build app.psgi with different handlers for different file extensions. Somthing as in the Apache:

<LocationMatch "(\.m|\.mh|\/)$">
     SetHandler              perl-script
     PerlHandler             MyApp::Mhandler
</LocationMatch>

<LocationMatch "(\.p|\.ph)$">
     SetHandler              perl-script
     PerlHandler             MyApp::Phandler
</LocationMatch>

Now I have:

#app for handle .m and .mh
my $Mapp = Some::PSGI->handler( sub {
...
});

#app for handling .p and .ph
my $Papp = SomeOther::PSGI->handler( sub {
...
});

but how to use the builder?

builder {

    #any extension what is not .m .mh .p .ph - handle as static
    #but, only when the request have any extension
    enable "Plack::Middleware::Static",
      path => __what here__, ???
      root => "/my/doc/root";

    #and what here to achieve the following "rules".

    #??? $Papp
    #default $Mapp
};

Needed “rules”:

  • if the request does not have any extension, or the request ends with ‘/’
    • should be handled with $Mapp
  • if the request ends with some extension, then
    • .m and .mh should be handled by $Mapp
    • .p and .ph should be handled by $Papp
    • all other files with extensions (like .css .js .pdf .jpg …) should be handled as static.

Sure, will be much easier put every static file into some tree, but the current app is given and now i only want move it into Startman, refactoring – later.

  • 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-06T09:22:37+00:00Added an answer on June 6, 2026 at 9:22 am
    use strictures;
    use Plack::Request qw();
    use Plack::Builder qw(builder enable);
    use Tie::REHash do_cache => 1;
    
    tie my %location_match, 'Tie::REHash';
    %location_match = (
        qr'(\.m|\.mh|/|/[^.]+)$' => sub {[200,[],['Mhandler']]},
        qr'(\.p|\.ph)$'          => sub {[200,[],['Phandler']]},
    );
    
    my $app = sub {
        my ($env) = @_;
        my $req = Plack::Request->new($env);
        my $res;
        if ($location_match{$req->path_info}) {
            printf "path [%s] dispatches to %s\n", $req->path_info, $location_match{$req->path_info};
            $res = $location_match{$req->path_info};
        } else {
            die sprintf "no match for path [%s], check routing configuration\n", $req->path_info;
        }
        return $res->($env);
    };
    
    builder {
        enable 'Static', path => sub {
            my ($path) = @_;
            if ($location_match{$path}) {
                print "redispatch\n";
                return;
            } elsif ($path =~ qr'/ [^/]+ [.] [^/]+ $'x) {
                return 1;
            } else {
                die "no match for path [$path], check routing configuration\n";
            }
        }, root => './htdocs/';
        $app;
    }
    
    __END__
    GET 'http://localhost:5000/foo?bar=baz;quux#fnord'
    GET 'http://localhost:5000/foo/?bar=baz;quux#fnord'
    GET 'http://localhost:5000/foo.m?bar=baz;quux#fnord'
    GET 'http://localhost:5000/foo.mh?bar=baz;quux#fnord'
    GET 'http://localhost:5000/foo.p?bar=baz;quux#fnord'
    GET 'http://localhost:5000/foo.ph?bar=baz;quux#fnord'
    GET 'http://localhost:5000/foo.css?bar=baz;quux#fnord'
    GET 'http://localhost:5000/foo.js?bar=baz;quux#fnord'
    GET 'http://localhost:5000/foo.pdf?bar=baz;quux#fnord'
    GET 'http://localhost:5000/foo.jpg?bar=baz;quux#fnord'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my sample code: SPWeb web = SPContext.Current.Web SPList list = web.Lists[TestList]; try
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
This is my first time using Magento. I upgraded this site from 1.4.1.1 to
this is my first question in here, and I would like to ask if
This question is directly related to this SO question I posed about 15 minutes
This question is kind of a follow up to this question I asked a
This should be a simple one: I have an observableArray object called To in
This sequence satisfies a(n+2) = 2 a(n+1) + 2 a(n). and also a(n)=[(1+sqrt(3))^(n+2)-(1-sqrt(3))^(n+2)]/(4sqrt(3)). I

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.