aboutsummaryrefslogtreecommitdiff
path: root/lib/Apache/Inject/Handler.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Apache/Inject/Handler.pm')
-rw-r--r--lib/Apache/Inject/Handler.pm44
1 files changed, 22 insertions, 22 deletions
diff --git a/lib/Apache/Inject/Handler.pm b/lib/Apache/Inject/Handler.pm
index 6c1a282..794eb2f 100644
--- a/lib/Apache/Inject/Handler.pm
+++ b/lib/Apache/Inject/Handler.pm
@@ -28,6 +28,28 @@ my $doc = qr{
\z
}xmsi;
+sub handler {
+ my $r = shift;
+
+ return DECLINED if not $r->content_type eq 'text/html';
+
+ my $content = ${$r->slurp_filename};
+ return DECLINED if not $content =~ /$doc/;
+
+ if (not $r->document_root) {
+ $r->warn('Inject: Declining request due to empty document root');
+ return DECLINED;
+ }
+
+ print $+{head} if $+{head};
+ inject($r, "InjectHead");
+ print $+{body} if $+{body};
+ inject($r, "InjectFoot");
+ print $+{rest} if $+{rest};
+
+ return OK;
+}
+
sub inject {
my ($r, $var) = @_;
@@ -56,26 +78,4 @@ sub inject {
close $fh;
}
-sub handler {
- my $r = shift;
-
- return DECLINED if not $r->content_type eq 'text/html';
-
- my $content = ${$r->slurp_filename};
- return DECLINED if not $content =~ /$doc/;
-
- if (not $r->document_root) {
- $r->warn('Inject: Declining request due to empty document root');
- return DECLINED;
- }
-
- print $+{head} if $+{head};
- inject($r, "InjectHead");
- print $+{body} if $+{body};
- inject($r, "InjectFoot");
- print $+{rest} if $+{rest};
-
- return OK;
-}
-
1;