refactor(http)!: fix cascade dart good practices + docs

This commit is contained in:
2023-04-13 23:29:27 +02:00
parent 216a6c2aae
commit 07c2f4aeff
33 changed files with 303 additions and 974 deletions
@@ -18,12 +18,21 @@ import 'package:wyatt_http_client/src/models/middleware_context.dart';
import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/models/middleware_response.dart';
/// {@template middleware}
/// A middleware is a class that can intercept requests and responses
/// and modify them before they are sent to the server or before they
/// are returned to the client.
/// {@endtemplate}
abstract class Middleware {
Middleware();
/// {@macro middleware}
const Middleware();
/// The name of the middleware.
String getName();
}
mixin OnRequestMiddleware {
/// Performs an action before the request is sent to the server.
Future<MiddlewareRequest> onRequest(
MiddlewareContext context,
MiddlewareRequest request,
@@ -31,6 +40,7 @@ mixin OnRequestMiddleware {
}
mixin OnResponseMiddleware {
/// Performs an action before the response is returned to the client.
Future<MiddlewareResponse> onResponse(
MiddlewareContext context,
MiddlewareResponse response,