🌻 📖 Test2::Tools::HTTP::Apps

NAME

Test2::Tools::HTTP::Apps - App container class for Test2::Tools::HTTP

VERSION

version 0.11

SYNOPSIS

DESCRIPTION

This acts as a container for zero or more PSGI applications that have been added using Test2::Tools::HTTP's psgi_app_add method. It is used by a user agent wrapper (Test2::Tools::HTTP::UA) class to dispatch requests to the correct PSGI app.

CONSTRUCTOR

new

 my $apps = Test2::Tools::HTTP::Apps->new;

This class is a singleton, so this always returns the same instance.

METHODS

uri_key

 my $key = $apps->uri_key($url);

This function returns the URI key given a fully qualified URL. The key usually contains the schema, host and port but not the path or other components of the URI. The actual key format is subject to change and you should not depend on it.

add_psgi

 $apps->add_psgi($uri, $app) = @_;

Add the given PSGI app to the container. The URI should specify the URL used to access the app.

del_psgi

 $apps->del_psgi($uri);

Remove the app with the given URI from the container.

base_url

 my $url = $apps->base_url;

This is the base URL used to qualify relative URLs. It is an instance of URI.

uri_to_app

 my $app = $apps->uri_to_app($uri);

Given a URL (possibly relative) this function returns the PSGI app for it. If there are no apps registered for the URL then it will return undef.

uri_to_tester

 my $tester = $apps->uri_to_tester;

Same as uri_to-tester except it returns the a Plack::Test wrapped around the PSGI application.

SEE ALSO

Test2::Tools::HTTP
Test2::Tools::HTTP::UA

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2018-2022 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.