qpsmtpd/plugins/http_config
Robert Spier 90daeb3786 r483@dog: rspier | 2005-07-06 21:17:00 -0700
The great plugin renaming in the name of inheritance and standardization commit.
 
 1. new concept of standard hook_ names.
 2. Plugin::init
 3. renamed many subroutines in plugins (and cleaned up register subs)
 4. updated README.plugins
 


git-svn-id: https://svn.perl.org/qpsmtpd/trunk@479 958fd67b-6ff1-0310-b445-bb7760255be9
2005-07-07 04:17:39 +00:00

50 lines
1.2 KiB
Plaintext

=head1 NAME
http_config
=head1 DESCRIPTION
Example config plugin. Gets configuration data via http requests.
=head1 CONFIG
http_config is configured at plugin loading time via the plugins
config. Load the plugin with a list of urls like the following (on one line)
http_config http://localhost/~smtpd/config/ http://www.example.com/cgi-bin/qp?config=
Looking to config "me", qpsmtpd will try loading
http://localhost/~smtpd/config/me and if failing that try
http://www.example.com/cgi-bin/qp?config=me
=head1 BUGS
http_config doesn't do any caching. It should do some simple caching
to be used in production.
=cut
use LWP::Simple qw(get);
my @urls;
sub register {
my ($self, $qp, @args) = @_;
@urls = @args;
}
sub hook_config {
my ($self, $transaction, $config) = @_;
$self->log(LOGNOTICE, "http_config called with $config");
for my $url (@urls) {
$self->log(LOGDEBUG, "http_config loading from $url");
my @config = split /[\r\n]+/, (get "$url$config" || "");
chomp @config;
@config = grep { $_ and $_ !~ m/^\s*#/ and $_ =~ m/\S/ } @config;
close CF;
# $self->log(LOGNOTICE, "returning http_config for $config ",Data::Dumper->Dump([\@config], [qw(config)]));
return (OK, @config) if @config;
}
return DECLINED;
}