Gantry::Conf::Provider::HTTP - Base class for all Gantry::Conf::Provider::HTTP modules


Gantry documentation Contained in the Gantry distribution.

Index


Code Index:

NAME

Top

Gantry::Conf::Provider::HTTP - Base class for all Gantry::Conf::Provider::HTTP modules

SYNOPSIS

Top

    use base 'Gantry::Conf::Provider::HTTP';

    my $response = $self->fetch( $url );

DESCRIPTION

Top

This module handle the transport over http for all modules that want to pull content from a web server. I know it's easy to do, but I want it in one place.

METHODS

Top

fetch

Give it a url, it'll give you the content from it (including error responses).

SEE ALSO

Top

Gantry(3), Gantry::Conf(3), Gantry::Conf::Tutorial(3), Ganty::Conf::FAQ(3)

LIMITATIONS

Top

AUTHOR

Top

Phil Crow <pcrow@sunflowerbroadband.com>

COPYRIGHT and LICENSE

Top


Gantry documentation Contained in the Gantry distribution.

package Gantry::Conf::Provider::HTTP; 

#####################################################################
# 
#  Name        :    Gantry::Conf::Provider::HTTP
#  Author      :    Phil Crow <pcrow@sunflowerbroadband.com> 
#
#  Description :    Base class that all Gantry::Conf::Provider::HTTP::*
#                   modules should inherit from.  
#
#####################################################################

use strict;
use warnings; 

use base 'Gantry::Conf::Provider';

use Carp;
use LWP::UserAgent;

sub fetch {
    my $self     = shift;
    my $url      = shift;

    my $ua       = LWP::UserAgent->new();
    $ua->agent( 'GantryConf/0.1' );

    my $request  = HTTP::Request->new( GET => $url );
    my $response = $ua->request( $request );

    return $response->content if ( $response->is_success );

    croak $response->status_line;
}

1;

__END__