Re: [cgiapp] Can I override CAP::Dispatch::dispatch_path() ?

2009-03-23 Thread silent
just:

#!perl
use Mydispatch;
Mydispatch-dispatch();



and I write a simple one:


/MyApp# more Base.pm Foo.pm Bar.pm Dispatch.pm ../myapp.fcgi
::
Base.pm
::
package MyApp::Base;

use base 'CGI::Application::FastCGI';

1;
::
Foo.pm
::
package MyApp::Foo;

use base 'MyApp::Base';

sub setup {
my $self = shift;
$self-mode_param(
param = 'rm',
path_info = '1',
);
$self-start_mode('foo1');
$self-run_modes(
'foo1' = 'foo1',
'foo2' = 'foo2',
);
}

sub foo1 {
my $self = shift;
return this is foo 1;
}

sub foo2 {
my $self = shift;
return this is foo 2;
}

1;
::
Bar.pm
::
package MyApp::Bar;

use base 'MyApp::Base';

sub setup {
my $self = shift;
$self-mode_param(
param = 'rm',
path_info = '1',
);
$self-start_mode('bar1');
$self-run_modes(
'bar1' = 'bar1',
'bar2' = 'bar2',
);
}

sub bar1 {
my $self = shift;
return this is bar 1;
}

sub bar2 {
my $self = shift;
return this is bar 2;
}

1;
::
Dispatch.pm
::
package MyApp::Dispatch;

use base 'CGI::Application::Dispatch';

sub dispatch_path {
my $uri = $ENV{'REQUEST_URI'};
my $name = $ENV{'SCRIPT_NAME'};

$uri =~s/^$name//;
$uri =~s/\?.*$//;

$ENV{'PATH_INFO'} = $uri;
warn [+] $uri\n;
return $uri;
}

sub dispatch_args {
return {
prefix = 'MyApp',
table = [
'' = { app = 'Foo' },
':app/:rm' = {},
],
};
}

1;
::
../myapp.fcgi
::
#!/usr/bin/perl

use lib /var/www/fcgi/myapp;
use MyApp::Dispatch;

MyApp::Dispatch-dispatch();




### nginx config:

  location /myapp {
fastcgi_pass unix:/tmp/fcgi.sock;
include fastcgi_params;
fastcgi_param SCRIPT_NAME /myapp;
  }

### start the fastcgi script with lighttpd's spawn-fcgi
spawn-fcgi -u www-data -g www-data -c / -s /tmp/fcgi.sock -f
/path/to/myapp.fcgi -n






2009/3/21 Michael Peters mpet...@plusthree.com:
 silent wrote:

 but it seems not work, all the request goto the default app default
 run_mode.

 You don't show where you're using Mydispatch or how your using it.

 --
 Michael Peters
 Plus Three, LP


#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




Re: [cgiapp] Can I override CAP::Dispatch::dispatch_path() ?

2009-03-22 Thread Michael Peters

silent wrote:


but it seems not work, all the request goto the default app default run_mode.


You don't show where you're using Mydispatch or how your using it.

--
Michael Peters
Plus Three, LP


#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####




[cgiapp] Can I override CAP::Dispatch::dispatch_path() ?

2009-03-21 Thread silent
Hi,

I want to override dispatch_path() with FastCGI,
because some http server does not set the $ENV{PATH_INFO},
I want to set it by my self,
but it seems not work, all the request goto the default app default run_mode.


package Mydispatch;
use base 'CGI::Application::Dispatch';

sub dispatch_path {
my $uri = $ENV{'REQUEST_URI'};
my $name = $ENV{'SCRIPT_NAME'};

$uri =~s/^$name//;
$uri =~s/\?.*$//;
$ENV{'PATH_INFO'} = $uri;
warn [+] $uri\n;### the warn only print for one time when I
start the script.
return $uri;
}

sub dispatch_args {
return {
prefix = 'APP::User',
table  = [
''  = { app = 'Foo' },    always here.
':app/:rm'  = {},
],
};
}
1;


the APP::User.pm  has  use base 'CGI::Application::FastCGI';
and it seems to be a perl problem, not a CAP-dispatch problem, but I
can not fix it right now.

thanks!

#  CGI::Application community mailing list  
####
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:  http://cgiapp.erlbaum.net/ ##
####