It is very surprising how UA knows which server to send requests.
use Mojolicious::Lite;
use Mojo::UserAgent;
get '/test' => sub{ shift->render( text => 'Ok' ) };
print "Response: " .Mojo::UserAgent->new->get( '/test' )->result->body ."\n";
1;
Document somewhere that Mojolicious::Lite changes Mojo::UserAgent::Server.
I found nothing here https://docs.mojolicious.org/Mojolicious/Lite or here https://docs.mojolicious.org/Mojo/UserAgent
and even here https://docs.mojolicious.org/Mojo/UserAgent/Server
It seems this could be bit dangerous, because if a 3rd party module loads Mojolicious::Lite, then UA in current module module is not just clean UA:
use Mojo::UserAgent;
use Some::Module;
my $ua = Mojo::UserAgent->new;
Though, overall I like the idea that if the URL is not absolute, then the request goes to the current application.
It is very surprising how UA knows which server to send requests.
Document somewhere that Mojolicious::Lite changes Mojo::UserAgent::Server.
I found nothing here https://docs.mojolicious.org/Mojolicious/Lite or here https://docs.mojolicious.org/Mojo/UserAgent
and even here https://docs.mojolicious.org/Mojo/UserAgent/Server
It seems this could be bit dangerous, because if a 3rd party module loads Mojolicious::Lite, then UA in current module module is not just clean UA:
Though, overall I like the idea that if the URL is not absolute, then the request goes to the current application.