ispectify_http 4.1.3-dev12 copy "ispectify_http: ^4.1.3-dev12" to clipboard
ispectify_http: ^4.1.3-dev12 copied to clipboard

An additional package for http (logging and handling).

Standard HTTP client integration for ISpectify logging system

pub version License: MIT GitHub stars

Pub likes Pub points

🔍 Overview #

ISpectify HTTP provides seamless integration between Dart's standard HTTP client and the ISpectify logging system.

🌐 HTTP Logging • 📊 Response Tracking • ❌ Error Handling • ⚡ Performance

Enhance your HTTP debugging workflow by automatically capturing and logging all standard HTTP client interactions. Ideal for applications using Dart's built-in HTTP client or when you need a lightweight HTTP logging solution.

🎯 Key Features #

  • 🌐 HTTP Request Logging: Automatic logging of all HTTP requests
  • 📊 Response Tracking: Detailed response logging with timing information
  • Error Handling: Comprehensive error logging with stack traces
  • 🔍 Request Inspection: Headers, body, and parameter logging
  • Performance Metrics: Request/response timing and size tracking
  • 🎛️ Lightweight: Minimal overhead with the standard HTTP client

🔧 Configuration Options #

Basic Configuration #

final client = InterceptedClient.build(
  interceptors: [
    ISpectifyHttpInterceptor(
      ispectify: ispectify,
      settings: ISpectifyHttpSettings(
        // Request logging
        printRequestHeaders: true,
        printRequestBody: true,
        
        // Response logging
        printResponseHeaders: true,
        printResponseBody: true,
        
        // Error handling
        printErrorDetails: true,
        
        // Performance
        trackRequestTime: true,
      ),
    ),
  ],
);

Advanced Filtering #

final client = InterceptedClient.build(
  interceptors: [
    ISpectifyHttpInterceptor(
      ispectify: ispectify,
      settings: ISpectifyHttpSettings(
        // Filter sensitive headers
        headerFilter: (headers) => Map.from(headers)
          ..remove('authorization'),
        
        // Filter request bodies
        requestBodyFilter: (body) {
          if (body.contains('password')) {
            return body.replaceAll(RegExp(r'"password":"[^"]*"'), '"password":"***"');
          }
          return body;
        },
        
        // Custom log levels
        requestLogLevel: LogLevel.debug,
        responseLogLevel: LogLevel.info,
        errorLogLevel: LogLevel.error,
      ),
    ),
  ],
);

📦 Installation #

Add ispectify_http to your pubspec.yaml:

dependencies:
  ispectify_http: ^4.1.3

🚀 Quick Start #

import 'package:http/http.dart' as http;
import 'package:ispectify_http/ispectify_http.dart';
import 'package:ispectify/ispectify.dart';

void main() {
  final ispectify = ISpectify();
  
  // Create HTTP client with ISpectify interceptor
  final client = InterceptedClient.build(
    interceptors: [
      ISpectifyHttpInterceptor(
        ispectify: ispectify,
        settings: ISpectifyHttpSettings(
          printRequestHeaders: true,
          printResponseHeaders: true,
          printRequestBody: true,
          printResponseBody: true,
        ),
      ),
    ],
  );
  
  // All HTTP requests will be automatically logged
  final response = await client.get(
    Uri.parse('https://api.example.com/data'),
  );
  
  // Don't forget to close the client
  client.close();
}

⚙️ Advanced Features #

Custom Log Formatting #

final client = InterceptedClient.build(
  interceptors: [
    ISpectifyHttpInterceptor(
      ispectify: ispectify,
      settings: ISpectifyHttpSettings(
        requestFormatter: (request) => 'HTTP ${request.method} ${request.url}',
        responseFormatter: (response) => 'Response ${response.statusCode} (${response.body.length} bytes)',
      ),
    ),
  ],
);

Environment-based Configuration #

final client = InterceptedClient.build(
  interceptors: [
    ISpectifyHttpInterceptor(
      ispectify: ispectify,
      settings: kDebugMode 
        ? ISpectifyHttpSettings.debug() // Full logging in debug
        : ISpectifyHttpSettings.production(), // Minimal logging in production
    ),
  ],
);

Multiple HTTP Clients #

// API client
final apiClient = InterceptedClient.build(
  interceptors: [
    ISpectifyHttpInterceptor(
      ispectify: ispectify,
      tag: 'API',
    ),
  ],
);

// Analytics client
final analyticsClient = InterceptedClient.build(
  interceptors: [
    ISpectifyHttpInterceptor(
      ispectify: ispectify,
      tag: 'Analytics',
    ),
  ],
);

📚 Examples #

See the example/ directory for complete integration examples with different HTTP client configurations.

🏗️ Architecture #

ISpectifyHttp integrates with the standard HTTP client through interceptors:

Component Description
HTTP Interceptor Captures HTTP requests and responses
Request Logger Logs request details (headers, body, params)
Response Logger Logs response data and timing
Error Handler Captures and logs HTTP errors
Performance Tracker Measures request/response times

🤝 Contributing #

Contributions are welcome! Please read our contributing guidelines and submit pull requests to the main branch.

📄 License #

This project is licensed under the MIT License - see the LICENSE file for details.

  • ispectify - Foundation logging system
  • ispectify_dio - Dio HTTP client integration
  • ispect - Main debugging interface
  • http - Standard HTTP client for Dart

Built with ❤️ for the Flutter community

0
likes
0
points
1.43k
downloads

Publisher

verified publishershodev.live

Weekly Downloads

An additional package for http (logging and handling).

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

http_interceptor, ispectify

More

Packages that depend on ispectify_http