Skip to content

Use a separate configuration for every client - #32

Merged
pavog merged 1 commit into
masterfrom
separate-configuration
Oct 20, 2026
Merged

pavog merged 1 commit into
masterfrom
separate-configuration

Conversation

@pavog

@pavog pavog commented Oct 19, 2026

Copy link
Copy Markdown
Member

ModrinthAPIClient used Configuration::getDefaultConfiguration() when no configuration was passed. That is a process wide singleton, so all clients without an explicit configuration shared it:

  • new ModrinthAPIClient("token-a") followed by new ModrinthAPIClient("token-b") made the first client send token-b
  • creating a client without a token (new ModrinthAPIClient()) removed the token of every other client
  • setUserAgent() changed the user agent of all clients

Every client now creates its own Configuration. The boolean query string format is still set on the default configuration as well, because the ObjectSerializer reads it from there.

Breaking changes

  • Changes made to Configuration::getDefaultConfiguration() (e.g. setHost()) no longer apply to clients created without a configuration. Pass your own Configuration to the constructor instead.

@pavog pavog added this to the v5 milestone Oct 19, 2026
@pavog
pavog requested a review from JulianVennen October 19, 2026 16:07
@pavog
pavog merged commit 03c3a67 into master Oct 20, 2026
4 checks passed
@pavog
pavog deleted the separate-configuration branch October 20, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants