Skip to content

Bootstrap and Configuration

Arun Prakash edited this page Sep 21, 2025 · 2 revisions

⚙️ Bootstrap & Configuration

Use the BootstrapBuilder to configure the client: timeouts, headers, user agent, authorization, middlewares, and more.

Common setup

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(),
);

Middlewares & Interceptors

  • withMiddleware / withMiddlewares to add IWordpressMiddleware
  • withDioInterceptor to add Dio interceptors (e.g., logging, retry)

Stats & preprocessing

  • withStatisticDelegate((baseUrl, count) { ... }) to observe request stats
  • withResponsePreprocessor((raw) => true/false) to short‑circuit response handling

You can also construct WordpressClient with a custom Dio instance via WordpressClient.fromDioInstance(...).

Clone this wiki locally