URL handlers are now completely replaced by Middleware
This commit is contained in:
parent
9b4e67b828
commit
30a2c09a36
11 changed files with 53 additions and 414 deletions
|
|
@ -45,6 +45,7 @@ sub call {
|
|||
} catch {
|
||||
# We don't have a logger object, so for now just warn() the error
|
||||
warn "Unable to instantiate WebGUI::Session - $_";
|
||||
return; # make sure $session assignment is undef
|
||||
};
|
||||
|
||||
if ( !$session ) {
|
||||
|
|
@ -85,7 +86,11 @@ sub call {
|
|||
|
||||
# Close the Session
|
||||
$env->{'webgui.session'}->close();
|
||||
#memory_cycle_ok( $env->{'webgui.session'} );
|
||||
delete $env->{'webgui.session'};
|
||||
|
||||
#use Test::Memory::Cycle;
|
||||
#memory_cycle_ok( $env );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
34
lib/WebGUI/Middleware/Snoop.pm
Normal file
34
lib/WebGUI/Middleware/Snoop.pm
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package WebGUI::Middleware::Snoop;
|
||||
use strict;
|
||||
use parent qw(Plack::Middleware);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Middleware::Snoop - sample middleware port of WebGUI::URL::Snoop
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is PSGI middleware for WebGUI.
|
||||
|
||||
It was ported from L<WebGUI::URL::Snoop>, back when we still had URL handlers.
|
||||
|
||||
L<WebGUI::URL::Snoop> described itself as "A URL handler that should never be called."
|
||||
|
||||
You might find this middleware useful as a template for creating other simple classes.
|
||||
|
||||
=cut
|
||||
|
||||
sub call {
|
||||
my $self = shift;
|
||||
my $env = shift;
|
||||
|
||||
my $path = $env->{PATH_INFO};
|
||||
if ($path =~ qr{^/abcdefghijklmnopqrstuvwxyz$}) {
|
||||
my $snoop = q|<html><head><title>Snoopy</title></head><body><div style="width: 600px; padding: 200px;">Why would you type in this URL? Really. What were you expecting to see here? You really need to get a life. Are you still here? Seriously, you need to go do something else. I think your boss is calling.</div></body></html>|;
|
||||
return [ 200, [ 'Content-Type' => 'text/html' ], [ $snoop ] ];
|
||||
} else {
|
||||
return $self->app->($env);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue