Class MagicWebSocketClientProfile.Builder<C>
java.lang.Object
dev.ua.theroer.magicutils.http.MagicWebSocketClientProfile.Builder<C>
- Type Parameters:
C- config type
- Enclosing class:
MagicWebSocketClientProfile<C>
Builder for
MagicWebSocketClientProfile.-
Method Summary
Modifier and TypeMethodDescriptionSets the base URL from config.bearerAuth(Function<C, String> tokenProvider) Adds an Authorization bearer token when the token is not blank.build()Builds the profile and binds it into the runtime.configure(BiConsumer<C, MagicWebSocketClient.Builder> customizer) Applies a builder customization that can read the config instance.configure(Consumer<MagicWebSocketClient.Builder> customizer) Applies a builder customization that does not depend on config.connectTimeout(Function<C, Duration> timeoutProvider) Overrides connect timeout from config.followRedirects(Function<C, Boolean> followProvider) Overrides redirect behavior from config.Adds a static header.Adds a config-driven header when the value is not null.Adds multiple config-driven headers.logger(Function<C, PlatformLogger> loggerProvider) Overrides the logger used by the client.Sets the config sections that should trigger client rebuilds.subprotocols(Function<C, List<String>> subprotocolsProvider) Sets config-driven subprotocols.Sets the default User-Agent from config.version(Function<C, HttpClient.Version> versionProvider) Overrides HTTP version from config.
-
Method Details
-
sections
Sets the config sections that should trigger client rebuilds.- Parameters:
sections- reload sections- Returns:
- builder for chaining
-
configure
public MagicWebSocketClientProfile.Builder<C> configure(BiConsumer<C, MagicWebSocketClient.Builder> customizer) Applies a builder customization that can read the config instance.- Parameters:
customizer- config-aware builder customizer- Returns:
- builder for chaining
-
configure
public MagicWebSocketClientProfile.Builder<C> configure(Consumer<MagicWebSocketClient.Builder> customizer) Applies a builder customization that does not depend on config.- Parameters:
customizer- builder customizer- Returns:
- builder for chaining
-
logger
Overrides the logger used by the client.- Parameters:
loggerProvider- logger provider- Returns:
- builder for chaining
-
baseUrl
Sets the base URL from config.- Parameters:
baseUrlProvider- config-driven base URL- Returns:
- builder for chaining
-
userAgent
Sets the default User-Agent from config.- Parameters:
userAgentProvider- config-driven user agent- Returns:
- builder for chaining
-
header
Adds a static header.- Parameters:
name- header namevalue- header value- Returns:
- builder for chaining
-
header
-
headers
-
bearerAuth
Adds an Authorization bearer token when the token is not blank.- Parameters:
tokenProvider- config-driven bearer token- Returns:
- builder for chaining
-
connectTimeout
Overrides connect timeout from config.- Parameters:
timeoutProvider- config-driven timeout- Returns:
- builder for chaining
-
followRedirects
Overrides redirect behavior from config.- Parameters:
followProvider- config-driven redirect toggle- Returns:
- builder for chaining
-
version
public MagicWebSocketClientProfile.Builder<C> version(Function<C, HttpClient.Version> versionProvider) Overrides HTTP version from config.- Parameters:
versionProvider- config-driven version- Returns:
- builder for chaining
-
subprotocols
-
build
Builds the profile and binds it into the runtime.- Returns:
- bound websocket client profile
-