Document that Mojolicious::Lite sets the default Mojo::UserAgent::Server app - #2334
Open
hikmetba-bit wants to merge 1 commit into
Open
hikmetba-bit wants to merge 1 commit into
hikmetba-bit wants to merge 1 commit into
Conversation
…ver app Fixes mojolicious#2283. Mojolicious::Lite::import() has always contained: # Make sure there's a default application for testing Mojo::UserAgent::Server->app($app) unless Mojo::UserAgent::Server->app; which makes the first Mojolicious::Lite app loaded in a process become the process-wide default for Mojo::UserAgent::Server, so relative URLs passed to Mojo::UserAgent reach it. This was previously undocumented in Mojolicious::Lite, Mojo::UserAgent or Mojo::UserAgent::Server's POD (confirmed by grepping all three), which is surprising and, as the reporter noted, can be a real gotcha: if a third-party module loads Mojolicious::Lite before your own application does, the global default may already point at that module's app instead of yours. Added a note to Mojolicious::Lite's DESCRIPTION and to Mojo::UserAgent::Server's "app" method POD, cross-referencing each other. Verification: documentation-only change, verified by reading the exact code path (Mojolicious/Lite.pm's import()) that performs this behavior, and confirming (via grep) it was genuinely undocumented before this change. No test suite run needed for a POD-only change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Member
|
Afraid we do not accept PRs with a Co-Authored-By an AI agent. You may of course use AI assistants, but a human has to take full responsibility for the patch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2283.
Mojolicious::Lite::import()has always contained:which makes the first
Mojolicious::Liteapp loaded in a process become the process-wide default forMojo::UserAgent::Server, so relative URLs passed toMojo::UserAgentreach it automatically.As the reporter found, this was previously undocumented in
Mojolicious::Lite,Mojo::UserAgent, orMojo::UserAgent::Server's POD (I confirmed this by grepping all three before writing anything). It's a genuinely useful behavior, but also a real gotcha they pointed out: if a third-party module loadsMojolicious::Litebefore your own application does,Mojo::UserAgent::Server->appmay already point at that module's app instead of yours, since it's a process-wide, load-order-dependent global.Change
Added a short note to:
Mojolicious::Lite'sDESCRIPTION, right after the existing SYNOPSIS/tutorial pointer.Mojo::UserAgent::Server'sappmethod POD, where the reporter specifically looked and found nothing.Both cross-reference each other.
Verification
Documentation-only change. Verified by reading the exact code path (
Mojolicious::Lite::import(), theunless Mojo::UserAgent::Server->appguard) that performs this behavior, and confirming withgrep -rn "UserAgent::Server" lib/Mojolicious/Lite.pm lib/Mojolicious.pm lib/Mojo/UserAgent/Server.pmthat it was genuinely undocumented before this change. No test suite run needed for a POD-only change (nothing here changes runtime behavior).🤖 Generated with Claude Code