multiple mounts in builder with same enables

11 views
Skip to first unread message

ivo welch

unread,
Aug 22, 2016, 10:38:09 PM8/22/16
to psgi-plack

this is just an inquiry for whether there is some syntactic sugar here.  I have an app in mount "/", plus a few lines like:

  mount "/css" => builder {
    enable 'ConditionalGET';
    enable 'ETag', file_etag => [qw/inode mtime size/], ;
    enable 'ContentLength';
    Plack::App::File->new(root => "css")->to_app;
  };
  mount "/images" => builder {
    enable 'ConditionalGET';
    enable 'ETag', file_etag => [qw/inode mtime size/], ;
    enable 'ContentLength';
    Plack::App::File->new(root => "images")->to_app;
  };

same for js, favicon.ico, and a few more.  can this be combined?  aka, something like

  mount ("/static", "/css", "/images", "/js", "*.png", ... ) => builder {
    enable 'ConditionalGET';
    enable 'ETag', file_etag => [qw/inode mtime size/], ;
    enable 'ContentLength';
    Plack::App::File->new(root => $_)->to_app;
  };

this pseudo code is obvious nonsense.  it is just to show intent.  easy?  impossible?

regards, /iaw

Tatsuhiko Miyagawa

unread,
Aug 22, 2016, 10:40:24 PM8/22/16
to psgi-plack
Just use a regular perl.

for my $path (qw( /css /static /images /js )) {
  mount $path => builder {
    …
  }
}


--

---
You received this message because you are subscribed to the Google Groups "psgi-plack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psgi-plack+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages