ASP4
view release on metacpan or search on metacpan
- ->is_subrequest means that a subrequest context will not clobber ->current.
2012-02-24 1.083
- A wild Meta.json appeared in 1.082!
2012-02-24 1.082
- Response->Redirect after Response->TrapInclude was causing the redirect to fail.
- This release introduces a hack to fix it, by writing a meta tag to the client.
2012-02-13 1.081
- Updated logging of errors so that it outputs something interesting, instead
of a blank line.
- Running under mod_perl should now correctly support full RESTful interfaces.
2012-02-12 1.080
- Added support for multiple external "routes.json" files.
2012-02-07 1.079
- Errors output to the stderr are now derived directly from $@ not from any
parsed version of it.
README.markdown view on Meta::CPAN
'reply-to' => $msg->sender->email,
to => $msg->recipient->email,
subject => 'New in-club message',
message => <<"MSG",
Dear user,
Another user (@{[ $msg->sender->email ]}) has sent you an in-club message.
Please login and view it on your profile at http://$ENV{HTTP_HOST}/
Yours,
The "In Club"
MSG
);
# Finally:
return $msg;
inc/Module/Install/Fetch.pm view on Meta::CPAN
require Cwd;
my $dir = Cwd::getcwd();
chdir $args{local_dir} or return if exists $args{local_dir};
if (eval { require LWP::Simple; 1 }) {
LWP::Simple::mirror($args{url}, $file);
}
elsif (eval { require Net::FTP; 1 }) { eval {
# use Net::FTP to get past firewall
my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600);
$ftp->login("anonymous", 'anonymous@example.com');
$ftp->cwd($path);
$ftp->binary;
$ftp->get($file) or (warn("$!\n"), return);
$ftp->quit;
} }
elsif (my $ftp = $self->can_run('ftp')) { eval {
# no Net::FTP, fallback to ftp.exe
require FileHandle;
my $fh = FileHandle->new;
local $SIG{CHLD} = 'IGNORE';
unless ($fh->open("|$ftp -n")) {
warn "Couldn't open ftp: $!\n";
chdir $dir; return;
}
my @dialog = split(/\n/, <<"END_FTP");
open $host
user anonymous anonymous\@example.com
cd $path
binary
get $file $file
quit
END_FTP
foreach (@dialog) { $fh->print("$_\n") }
$fh->close;
} }
else {
warn "No working 'ftp' program available!\n";
chdir $dir; return;
}
unless (-f $file) {
warn "Fetching failed: $@\n";
chdir $dir; return;
lib/ASP4.pm view on Meta::CPAN
$Server->Mail(
from => 'root@localhost',
'reply-to' => $msg->sender->email,
to => $msg->recipient->email,
subject => 'New in-club message',
message => <<"MSG",
Dear user,
Another user (@{[ $msg->sender->email ]}) has sent you an in-club message.
Please login and view it on your profile at http://$ENV{HTTP_HOST}/
Yours,
The "In Club"
MSG
);
# Finally:
return $msg;
});
};
lib/ASP4/Error.pm view on Meta::CPAN
message => "If can, can. If no can, no can!"
);
}
=head1 DESCRIPTION
ASP4 provides a simple means of dealing with errors. It emails them, by default,
to an email address you specify.
Sometimes that is not convenient. Maybe you want to do something special with
the error - like log it someplace special.
ASP4::Error is a simple representation of a server-side error.
=head1 PUBLIC READ-ONLY PROPERTIES
=head2 domain
C<<$Config->errors->domain>> or C<$ENV{HTTP_HOST}>
=head2 request_uri
lib/ASP4/RequestFilter.pm view on Meta::CPAN
package My::MemberFilter;
use strict;
use warnings 'all';
use base 'ASP4::RequestFilter';
use vars __PACKAGE__->VARS;
sub run {
my ($self, $context) = @_;
if( $Session->{is_logged_in} )
{
# The user is logged in - we can ignore this request:
return $Response->Declined;
}
else
{
# The user must authenticate first:
$Session->{validation_errors} = { general => "You must log in first" };
return $Response->Redirect("/login/");
}# end if()
}
1;# return true:
Then, in your C<asp4-config.json>:
{
...
"web": {
lib/ASP4/Server.pm view on Meta::CPAN
ASP4::HTTPContext->current->config->web->www_root . $path;
}# end MapPath()
sub Mail
{
my $s = shift;
Mail::Sendmail::sendmail( @_ );
die $Mail::Sendmail::error if $Mail::Sendmail::error;
return $Mail::Sendmail::log;
}# end Mail()
sub RegisterCleanup
{
my ($s, $sub, @args) = @_;
$s->context->r->pool->cleanup_register( $sub, \@args );
}# end RegisterCleanup()
lib/ASP4/UserAgent.pm view on Meta::CPAN
=head1 NAME
ASP4::UserAgent - Execute ASP4 requests without a web server.
=head1 SYNOPSIS
B<NOTE:> 99.99% of the time you will access this via L<ASP4::API>.
my HTTP::Response $res = $api->ua->get('/index.asp?foo=bar');
my $res = $api->ua->post('/handlers/user.login', [
username => 'willy',
password => 'wonka',
]);
my $res = $api->ua->upload('/handlers/file.upload', [
foo => 'bar',
baz => 'bux',
file => ['/home/john/avatar.jpg']
]);
( run in 1.372 second using v1.01-cache-2.11-cpan-49f99fa48dc )