Added perlbal and Plack::Middleware::WebGUI to simplify psgi file
This commit is contained in:
parent
784e0bd73c
commit
b9bff5a2f6
6 changed files with 80 additions and 67 deletions
|
|
@ -3,7 +3,6 @@ use strict;
|
|||
use warnings;
|
||||
use base qw/Plack::Middleware::Static/;
|
||||
use Path::Class 'dir';
|
||||
__PACKAGE__->mk_accessors('settings');
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -17,13 +16,6 @@ Plack Middleware that delivers static files with .wgaccess awareness
|
|||
|
||||
sub _handle_static {
|
||||
my($self, $env) = @_;
|
||||
|
||||
# Populate $env with $self->settings so that we get consistent wg API behaviour
|
||||
my %settings = %{$self->settings};
|
||||
@{$env}{keys %settings} = values %settings;
|
||||
|
||||
# Populate $self->root from $SETTINGS so that it doesn't need to be specified in psgi file
|
||||
$self->root($settings{'wg.DOCUMENT_ROOT'});
|
||||
|
||||
#######################################
|
||||
# Copied from Plack::Middleware::Static::_handle_static
|
||||
|
|
|
|||
30
lib/Plack/Middleware/WebGUI.pm
Normal file
30
lib/Plack/Middleware/WebGUI.pm
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package Plack::Middleware::WebGUI;
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw/Plack::Middleware/;
|
||||
|
||||
__PACKAGE__->mk_accessors('root', 'config');
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Plack::Middleware::WebGUI
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Plack Middleware that populates $env
|
||||
|
||||
In the future we might want to read the site.conf here and then cache it
|
||||
|
||||
=cut
|
||||
|
||||
sub call {
|
||||
my $self = shift;
|
||||
my $env = shift;
|
||||
|
||||
$env->{'wg.WEBGUI_ROOT'} = $self->root;
|
||||
$env->{'wg.WEBGUI_CONFIG'} = $self->config;
|
||||
|
||||
$self->app->($env);
|
||||
}
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue