34 lines
No EOL
2 KiB
Perl
34 lines
No EOL
2 KiB
Perl
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; |