interceptors/http library

http_interceptor adapter that forwards every request — including 4xx/5xx responses — into TurboBridge.instance.network so it shows up on the DevTools timeline.

Add http_interceptor: ^3.0.0 to your app's pubspec.yaml — this file is only compiled when you import it, so the rest of turbo_bridge works without http_interceptor.

import 'package:http_interceptor/http_interceptor.dart';
import 'package:turbo_bridge/interceptors/http.dart';

final client = InterceptedClient.build(
  interceptors: [TurboBridgeHttpInterceptor()],
);
await client.get(Uri.parse('https://example.com'));

Add TurboBridgeHttpInterceptor LAST in the interceptors list so it observes the final, fully-decorated request (auth headers, etc.) and so the request instance it tags is the one actually sent.

http_interceptor v3 has no error hook on the interceptor itself — when the underlying Client.send throws (DNS failure, timeout, connection refused), interceptResponse never fires. To still surface those failures on the timeline, pass TurboBridgeHttpInterceptor.retryPolicy as the client's retryPolicy: the RetryPolicy exception hook does fire on a thrown send, and we use it to record the failure (without adding any retries of our own):

final interceptor = TurboBridgeHttpInterceptor();
final client = InterceptedClient.build(
  interceptors: [interceptor],
  retryPolicy: interceptor.retryPolicy(),       // logs send failures
);

Already using a RetryPolicy? Wrap it and keep its behavior: interceptor.retryPolicy(wrapping: myPolicy).

Classes

TurboBridgeHttpInterceptor
HttpInterceptor that records every HTTP exchange into the DevTools timeline. Drop it into an InterceptedClient / InterceptedHttp: