Caching is breaking something
This commit is contained in:
parent
e04b1ebc9d
commit
5982b2728c
3 changed files with 51 additions and 28 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
|
||||||
# This is just a temporary hack
|
# This is just a temporary hack
|
||||||
our $WEBGUI_ROOT = '/data/WebGUI';
|
our $WEBGUI_ROOT = '/data/WebGUI';
|
||||||
our $WEBGUI_DOMAINS = '/data/domains';
|
our $WEBGUI_DOMAINS = '/data/domains';
|
||||||
our $WEBGUI_CONFIG = 'dev.localhost.localdomain';
|
our $WEBGUI_CONFIG = 'dev.localhost.localdomain';
|
||||||
}
|
}
|
||||||
use local::lib $WEBGUI_ROOT;
|
use local::lib $WEBGUI_ROOT;
|
||||||
use WebGUI;
|
use WebGUI;
|
||||||
|
|
@ -11,26 +12,30 @@ use Plack::Builder;
|
||||||
|
|
||||||
my $app = sub {
|
my $app = sub {
|
||||||
my $env = shift;
|
my $env = shift;
|
||||||
$env->{'wg.WEBGUI_ROOT'} = $WEBGUI_ROOT;
|
$env->{'wg.WEBGUI_ROOT'} = $WEBGUI_ROOT;
|
||||||
$env->{'wg.WEBGUI_CONFIG'} = "$WEBGUI_CONFIG.conf";
|
$env->{'wg.WEBGUI_CONFIG'} = "$WEBGUI_CONFIG.conf";
|
||||||
$env->{'wg.DIR_CONFIG.WebguiRoot'} = $env->{'wg.WEBGUI_ROOT'};
|
$env->{'wg.DIR_CONFIG.WebguiRoot'} = $env->{'wg.WEBGUI_ROOT'};
|
||||||
$env->{'wg.DIR_CONFIG.WebguiConfig'} = $env->{'wg.WEBGUI_CONFIG'};
|
$env->{'wg.DIR_CONFIG.WebguiConfig'} = $env->{'wg.WEBGUI_CONFIG'};
|
||||||
WebGUI::handle_psgi($env);
|
WebGUI::handle_psgi($env);
|
||||||
};
|
};
|
||||||
|
|
||||||
# Apply some Middleware
|
# Apply some Middleware
|
||||||
builder {
|
builder {
|
||||||
|
|
||||||
# /extras
|
# /extras
|
||||||
enable Plack::Middleware::Static
|
enable Plack::Middleware::Static
|
||||||
path => qr{^/extras/}, root => "$WEBGUI_ROOT/www/";
|
path => qr{^/extras/},
|
||||||
|
root => "$WEBGUI_ROOT/www/";
|
||||||
|
|
||||||
# /uploads (ignore .wgaccess for now..)
|
# /uploads (ignore .wgaccess for now..)
|
||||||
enable Plack::Middleware::Static
|
enable Plack::Middleware::Static
|
||||||
path => qr{^/uploads/}, root => "$WEBGUI_DOMAINS/dev.localhost.localdomain/public/";
|
path => qr{^/uploads/},
|
||||||
|
root => "$WEBGUI_DOMAINS/dev.localhost.localdomain/public/";
|
||||||
|
|
||||||
enable Plack::Middleware::XFramework framework => 'WebGUI';
|
enable Plack::Middleware::XFramework framework => 'WebGUI';
|
||||||
|
|
||||||
enable Plack::Middleware::AccessLog format => "combined";
|
# Already enabled by plackup script
|
||||||
|
# enable Plack::Middleware::AccessLog format => "combined";
|
||||||
|
|
||||||
$app;
|
$app;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,13 @@ A reference to a WebGUI::Config object. One will be created if it isn't specifie
|
||||||
|
|
||||||
sub authen {
|
sub authen {
|
||||||
my ($request, $username, $password, $config) = @_;
|
my ($request, $username, $password, $config) = @_;
|
||||||
$request = Apache2::Request->new($request);
|
my $server;
|
||||||
my $server = Apache2::ServerUtil->server;
|
if ($request->isa('WebGUI::Session::Plack')) {
|
||||||
|
$server = $request->server;
|
||||||
|
} else {
|
||||||
|
$request = Apache2::Request->new($request);
|
||||||
|
$server = Apache2::ServerUtil->server; #instantiate the server api
|
||||||
|
}
|
||||||
my $status = Apache2::Const::OK;
|
my $status = Apache2::Const::OK;
|
||||||
|
|
||||||
# set username and password if it's an auth handler
|
# set username and password if it's an auth handler
|
||||||
|
|
@ -173,15 +178,15 @@ sub handler {
|
||||||
my $gotMatch = 0;
|
my $gotMatch = 0;
|
||||||
|
|
||||||
# handle basic auth
|
# handle basic auth
|
||||||
# my $auth = $request->headers_in->{'Authorization'};
|
my $auth = $request->headers_in->{'Authorization'};
|
||||||
# if ($auth =~ m/^Basic/) { # machine oriented
|
if ($auth =~ m/^Basic/) { # machine oriented
|
||||||
# # Get username and password from Apache and hand over to authen
|
# Get username and password from Apache and hand over to authen
|
||||||
# $auth =~ s/Basic //;
|
$auth =~ s/Basic //;
|
||||||
# authen($request, split(":", MIME::Base64::decode_base64($auth), 2), $config);
|
authen($request, split(":", MIME::Base64::decode_base64($auth), 2), $config);
|
||||||
# }
|
}
|
||||||
# else { # realm oriented
|
else { # realm oriented
|
||||||
# $request->push_handlers(PerlAuthenHandler => sub { return WebGUI::authen($request, undef, undef, $config)});
|
$request->push_handlers(PerlAuthenHandler => sub { return WebGUI::authen($request, undef, undef, $config)});
|
||||||
# }
|
}
|
||||||
|
|
||||||
|
|
||||||
# url handlers
|
# url handlers
|
||||||
|
|
@ -212,6 +217,8 @@ sub handler {
|
||||||
return Apache2::Const::DECLINED;
|
return Apache2::Const::DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sub handle_psgi {
|
sub handle_psgi {
|
||||||
my $env = shift;
|
my $env = shift;
|
||||||
require WebGUI::Session::Plack;
|
require WebGUI::Session::Plack;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ sub new {
|
||||||
require Plack::Response;
|
require Plack::Response;
|
||||||
|
|
||||||
my $request = Plack::Request->new( $p{env} );
|
my $request = Plack::Request->new( $p{env} );
|
||||||
my $response = $request->new_response;
|
my $response = $request->new_response(200);
|
||||||
|
|
||||||
my $self = bless {
|
my $self = bless {
|
||||||
%p,
|
%p,
|
||||||
|
|
@ -59,10 +59,17 @@ sub protocol { shift->request->protocol(@_) }
|
||||||
sub status { shift->response->status(@_) }
|
sub status { shift->response->status(@_) }
|
||||||
sub status_line {}
|
sub status_line {}
|
||||||
|
|
||||||
|
sub auth_type {
|
||||||
|
# should we support this?
|
||||||
|
}
|
||||||
|
|
||||||
# TODO: I suppose this should do some sort of IO::Handle thing
|
# TODO: I suppose this should do some sort of IO::Handle thing
|
||||||
my @body;
|
my @body;
|
||||||
sub print { shift; push @body, @_ }
|
sub print { shift; push @body, @_ }
|
||||||
|
|
||||||
|
my $sendfile;
|
||||||
|
sub sendfile { shift; $sendfile = shift; }
|
||||||
|
|
||||||
sub dir_config {
|
sub dir_config {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
|
|
@ -100,7 +107,11 @@ sub push_handlers {
|
||||||
|
|
||||||
sub finalize {
|
sub finalize {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->response->body(\@body);
|
if ($sendfile && open my $fh, '<', $sendfile) {
|
||||||
|
$self->response->body( $fh );
|
||||||
|
} else {
|
||||||
|
$self->response->body( $sendfile || \@body);
|
||||||
|
}
|
||||||
return $self->response->finalize;
|
return $self->response->finalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue