nmcfarl.orgRachel K Richard →Flash Remoting with Perl

Using FLAP with mod_perl

Useful links
FLAP (flash remoting with perl)
Flash Remoting overview
mod_perl

I'm using Flash Remoting with mod_perl to get my Flash application to talk to our database. To do so, I had to make a minor change to the FLAP.pm code that I downloaded, and created a PerlHandler called Apache::FLAP.pm. I also had to add a few lines to my httpd.conf. This process of setting up flash remoting with mod_perl is described below.


Changes to FLAP.pm


I found that I needed to use the Apache::Request object to print out the response or else it wouldn't work. This means replacing print with $r->print when appropriate. So I changed the _service function which is where the response gets printed out. The request object needs to get passed to the _service function.

About the request object: I just use the original code which creates the request object inside the service function, but you can also send it along via the PerlHandler.

Modified version of FLAP.pm


Apache Perl Handler
Next, I created a PerlHandler called Apache::FLAP.pm. It looks like:

package Apache::FLAP;                           
use strict;                              
use Flash::FLAP;                              
use Foo; # if registering this service                                            
       
sub handler 
{                                                              
    my $r = shift; 
    my $gateway = Flash::FLAP->new();  

    # register services 
    $gateway->registerService("foo", new Foo()); 
    
    # or, include base class path
    $gateway->setBaseClassPath("./basicservices/");

    $gateway->service(); 
}    
                                      
1;  



Apache httpd.conf file
Then I added some lines to my httpd.conf and I was all done.

The gateway url as configured below would be http://my_website.com/flap/
PerlModule Apache::FLAP

#Flash Remoting 
<Location /flap> #location, directory, whatever you want.
        SetHandler perl-script 
        PerlHandler Apache::FLAP 
</Location>

Everything else works the same way as explained in the FLAP instructions.

Email me at rachel@nmcfarl.org or at work at rkr@lanl.gov