Revision: 49
Author: phred_moyer
Date: 2006-08-01 20:33:26 -0700 (Tue, 01 Aug 2006)
ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=49&view=rev
Log Message:
-----------
Egads, these showed up on my dev box as committed but they aren't in the
sourceforge repository, and show up missing from the MANIFEST on checkout.
Added Paths:
-----------
trunk/t/lib/Apache/Foo/
trunk/t/lib/Apache/Foo/Bar.pm
trunk/t/lib/Apache/Foo/Filter.pm
trunk/t/lib/Apache/Foo/Foo.pm
Added: trunk/t/lib/Apache/Foo/Bar.pm
===================================================================
--- trunk/t/lib/Apache/Foo/Bar.pm (rev 0)
+++ trunk/t/lib/Apache/Foo/Bar.pm 2006-08-02 03:33:26 UTC (rev 49)
@@ -0,0 +1,47 @@
+package Apache::Foo::Bar;
+
+use strict;
+use warnings;
+
+use Apache::Constants qw( OK SERVER_ERROR );
+
+sub dispatch_baz {
+ my $class = shift;
+ my $r = Apache->request;
+ $r->log->debug("$class->dispatch_baz()");
+ $Apache::Foo::Bar::output = "pid $$";
+ $r->send_http_header('text/plain');
+ $r->print("$class->dispatch_baz()");
+ return OK;
+}
+
+sub post_dispatch {
+ my $class = shift;
+ my $r = shift;
+ $r->log->debug("$class->post_dispatch()");
+ # delay printing headers until all processing is done
+ $r->send_http_header('text/plain');
+ $r->print($Apache::Foo::Bar::output);
+}
+
+1;
+
+__END__
+
+here is a sample httpd.conf entry
+
+ PerlModule Apache::Dispatch
+ PerlModule Foo
+
+ <Location /Test>
+ SetHandler perl-script
+ PerlHandler Apache::Dispatch
+ DispatchPrefix Foo
+ DispatchExtras Pre Post Error
+ </Location>
+
+once you install it, you should be able to go to
+http://localhost/Test/Foo/foo
+or
+http://localhost/Test/Foo/Bar/foo
+etc, and get some results
Property changes on: trunk/t/lib/Apache/Foo/Bar.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/t/lib/Apache/Foo/Filter.pm
===================================================================
--- trunk/t/lib/Apache/Foo/Filter.pm (rev 0)
+++ trunk/t/lib/Apache/Foo/Filter.pm 2006-08-02 03:33:26 UTC (rev 49)
@@ -0,0 +1,26 @@
+package Apache::Foo::Filter;
+
+use strict;
+use warnings FATAL => 'all';
+
+sub handler {
+ my $r = shift;
+
+ $r->log->debug("Filtering response");
+ $r->send_http_header();
+
+ $r = $r->filter_register;
+
+ my $fh = $r->filter_input;
+
+ while (<$fh>) {
+ $r->log->debug("Filtering data $_");
+ # remove the underscores
+ s/_//g;
+ $r->log->debug("Filtered data $_");
+
+ print;
+ }
+}
+
+1;
\ No newline at end of file
Property changes on: trunk/t/lib/Apache/Foo/Filter.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/t/lib/Apache/Foo/Foo.pm
===================================================================
--- trunk/t/lib/Apache/Foo/Foo.pm (rev 0)
+++ trunk/t/lib/Apache/Foo/Foo.pm 2006-08-02 03:33:26 UTC (rev 49)
@@ -0,0 +1,102 @@
+package Foo::Foo;
+
+use Apache::Constants qw( OK SERVER_ERROR );
+use strict;
+
+our $AUTOLOAD;
+
+# declare the methods you want AUTOLOAD to capture by name
+# that is, AUTOLOAD will still be called, but $AUTOLOAD
+# will only be populated for methods you declare here
+#
+# read the camel book (3rd ed) pp326-329 before treading here...
+
+sub dispatch_baz;
+
+$Foo::Foo::output = undef;
+
+sub dispatch_foo {
+ my $self = shift;
+ my $r = shift;
+ $r->send_http_header('text/plain');
+ $r->print("Foo->dispatch_foo()");
+ print STDERR "Foo->dispatch_foo()\n";
+ return OK;
+}
+
+sub dispatch_bar {
+ # test returning not OK
+ print STDERR "Foo->dispatch_bar()\n";
+ return SERVER_ERROR;
+}
+
+sub pre_dispatch {
+ # test pre_dispatch call
+ print STDERR "Foo->pre_dispatch()\n";
+}
+
+sub post_dispatch {
+ # test post_dispatch call
+ print STDERR "Foo->post_dispatch()\n";
+}
+
+sub error_dispatch {
+ # test error_dispatch call
+ my $self = shift;
+ my $r = shift;
+ $r->send_http_header('text/plain');
+ $r->print("Yikes! Foo->dispatch_error()");
+ print STDERR "Yikes! Foo->dispatch_error()\n";
+ # you can return whatever you want...
+ return OK;
+}
+
+sub dispatch_index {
+ # test calls to /index or /
+ my $self = shift;
+ my $r = shift;
+ $r->send_http_header('text/plain');
+ $r->print("Foo->dispatch_index()");
+ print STDERR "Foo->dispatch_index()\n";
+ return OK;
+}
+
+sub AUTOLOAD {
+ my $self = shift;
+ my $r = shift;
+
+ our $AUTOLOAD;
+
+ # this might be a good use for Damian Conway's Switch.pm
+ return if $AUTOLOAD =~ m/::DESTROY$/;
+
+ print STDERR "asked for $AUTOLOAD\n";
+
+ if $AUTOLOAD =~ m/dispatch_baz/ {
+ $r->print("method $AUTOLOAD was declared!");
+ return OK;
+ }
+
+ $r->send_http_header('text/plain');
+ $r->print("sorry - method $AUTOLOAD not found");
+ return OK;
+}
+1;
+
+__END__
+
+here is a sample httpd.conf entry
+
+ PerlModule Apache::Dispatch
+ PerlModule Foo
+
+ <Location /Test>
+ SetHandler perl-script
+ PerlHandler Apache::Dispatch
+ DispatchPrefix Foo
+ DispatchExtras Pre Post Error
+ </Location>
+
+once you install it, you should be able to go to
+http://localhost/Test/Foo/foo
+and get some results
Property changes on: trunk/t/lib/Apache/Foo/Foo.pm
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|