generateHttpRequest method

  1. @override
Future<VoltronHttpRequest> generateHttpRequest(
  1. VoltronMap request
)
override

construct http request object

Implementation

@override
Future<VoltronHttpRequest> generateHttpRequest(VoltronMap request) async {
  var url = request.get<String>('url') ?? '';
  final method = request.get<String>("method") ?? '';
  if (isEmpty(url) || isEmpty(method)) {
    throw 'no valid url for request';
  }
  var body = request.get<String>('body') ?? '';
  var httpRequest = VoltronHttpRequest(
    url: url,
    connectTimeout: 10 * 1000,
    receiveTimeout: 10 * 1000,
    useCaches: false,
    method: method,
    body: body,
  );
  var headers = request.get<VoltronMap>('headers');
  if (headers != null) {
    _voltronMapToRequestHeaders(httpRequest, headers);
  }
  return httpRequest;
}