refactor(http)!: fix cascade dart good practices + docs
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
// Copyright (C) 2022 WYATT GROUP
|
||||
// Please see the AUTHORS file for details.
|
||||
//
|
||||
@@ -18,12 +17,25 @@
|
||||
import 'package:http/http.dart';
|
||||
import 'package:wyatt_http_client/src/utils/http_status.dart';
|
||||
|
||||
/// {@template middleware_response}
|
||||
/// A class that represents a middleware response.
|
||||
/// {@endtemplate}
|
||||
class MiddlewareResponse {
|
||||
BaseResponse httpResponse;
|
||||
/// {@macro middleware_response}
|
||||
const MiddlewareResponse({
|
||||
required this.httpResponse,
|
||||
});
|
||||
|
||||
// Proxy
|
||||
/// {@macro middleware_response}
|
||||
final BaseResponse httpResponse;
|
||||
|
||||
/// The status code of the response. (proxy)
|
||||
int get statusCode => httpResponse.statusCode;
|
||||
|
||||
/// The status of the response. (proxy)
|
||||
HttpStatus get status => HttpStatus.from(statusCode);
|
||||
|
||||
/// The body of the response. (proxy or empty string)
|
||||
String get body {
|
||||
if (httpResponse is Response) {
|
||||
return (httpResponse as Response).body;
|
||||
@@ -32,13 +44,13 @@ class MiddlewareResponse {
|
||||
}
|
||||
}
|
||||
|
||||
/// The content length of the response. (proxy)
|
||||
int? get contentLength => httpResponse.contentLength;
|
||||
|
||||
/// The headers of the response. (proxy)
|
||||
Map<String, String> get headers => httpResponse.headers;
|
||||
|
||||
MiddlewareResponse({
|
||||
required this.httpResponse,
|
||||
});
|
||||
|
||||
/// Returns a copy of this response with the given [httpResponse].
|
||||
MiddlewareResponse copyWith({
|
||||
BaseResponse? httpResponse,
|
||||
}) =>
|
||||
|
||||
Reference in New Issue
Block a user