-
Notifications
You must be signed in to change notification settings - Fork 14
Bootstrap and Configuration
Arun Prakash edited this page Sep 21, 2025
·
2 revisions
Use the BootstrapBuilder
to configure the client: timeouts, headers, user agent, authorization, middlewares, and more.
final client = WordpressClient.forSite(
siteUrl: Uri.parse('https://example.com'),
bootstrapper: (b) => b
.withRequestTimeout(const Duration(seconds: 30))
.withDefaultUserAgent('my-app/1.0')
.withDefaultHeaders({'x-app': 'my-app'})
.withDefaultAuthorization(
WordpressAuth.appPassword(user: 'user', appPassword: 'xxxx-xxxx'),
)
.withCache(ttl: const Duration(minutes: 5))
.withDebugMode(false)
.build(),
);
-
withMiddleware
/withMiddlewares
to addIWordpressMiddleware
-
withDioInterceptor
to add Dio interceptors (e.g., logging, retry)
-
withStatisticDelegate((baseUrl, count) { ... })
to observe request stats -
withResponsePreprocessor((raw) => true/false)
to short‑circuit response handling
You can also construct
WordpressClient
with a customDio
instance viaWordpressClient.fromDioInstance(...)
.