LWP::Protocol::PSGI

Override LWP's HTTP/HTTPS backend with your own PSGI applciation
Download

LWP::Protocol::PSGI Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Publisher Name:
  • Tatsuhiko Miyagawa
  • Publisher web site:
  • http://search.cpan.org/~miyagawa/

LWP::Protocol::PSGI Tags


LWP::Protocol::PSGI Description

Override LWP's HTTP/HTTPS backend with your own PSGI applciation LWP::Protocol::PSGI is a Perl module to hijack any code that uses LWP::UserAgent underneath such that any HTTP or HTTPS requests can be routed to your own PSGI application.Because it works with any code that uses LWP, you can override various WWW::*, Net::* or WebService::* modules such as WWW::Mechanize, without modifying the calling code or its internals. use WWW::Mechanize; use LWP::Protocol::PSGI; LWP::Protocol::PSGI->register($my_psgi_app); my $mech = WWW::Mechanize->new; $mech->get("http://amazon.com/"); # $my_psgi_app runsSYNOPSIS use LWP::UserAgent; use LWP::Protocol::PSGI; # can be Mojolicious, Catalyst ... any PSGI application my $psgi_app = do { use Dancer; setting apphandler => 'PSGI'; get '/search' => sub { return 'googling ' . params->{q}; }; dance; }; LWP::Protocol::PSGI->register($psgi_app); # can hijack any code or module that uses LWP::UserAgent underneath, with no changes my $ua = LWP::UserAgent->new; my $res = $ua->get("http://www.google.com/search?q=bar"); print $res->content; # "googling bar" Requirements: · Perl


LWP::Protocol::PSGI Related Software