| 1 | =head1 NAME | ||
| 2 | |||
| 3 | OpenFrame::WebApp::Segment::Decline::StaticContent - decline if request uri is for static content. | ||
| 4 | |||
| 5 | =head1 SYNOPSIS | ||
| 6 | |||
| 7 | $pipe->add_segment( OpenFrame::WebApp::Segment::StaticContent->new ) | ||
| 8 | |||
| 9 | =cut | ||
| 10 | |||
| 11 | package OpenFrame::WebApp::Segment::Decline::StaticContent; | ||
| 12 | |||
| 13 | use MIME::Types; | ||
| 14 | |||
| 15 | use base qw( OpenFrame::WebApp::Segment::Decline ); | ||
| 16 | |||
| 17 | our $VERSION = (split(/ /, '$Revision: 1.1 $'))[1]; | ||
| 18 | |||
| 19 | sub should_decline { | ||
| 20 | my $self = shift; | ||
| 21 | my $request = $self->store->get('OpenFrame::Request') || return; | ||
| 22 | my $uri = $request->uri || return; | ||
| 23 | my $mtype = MIME::Types->new->mimeTypeOf( $uri ) || return; | ||
| 24 | |||
| 25 | return 1 if ($mtype->subType eq 'css'); | ||
| 26 | return 1 if ($mtype->mediaType eq 'image'); | ||
| 27 | |||
| 28 | return 0; | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; | ||
| 32 | |||
| 33 | __END__ |