request method

Future<Map<String, dynamic>> request(
  1. OsrmRequest options
)

request method to make the request and return the raw response

Implementation

Future<Map<String, dynamic>> request(OsrmRequest options) async {
  try {
    final result = await client.get(
      serverBuilder(options),
      headers: {
        'Content-Type': 'application/json; charset=utf-8',
      },
    ).timeout(timeout);
    // CancellableOperation? operation;
    if (result.statusCode == 200) {
      return parseResponse(result.body);
    } else if (result.statusCode == 400) {
      var data = parseResponse(result.body);
      throw OsrmResponseException(
        code: OsrmResponseCode.fromString(data['code']),
        message: data['message'] ?? '',
      );
    }
    throw Exception('Invalid response code: ${result.statusCode}');
    // ignore: unused_catch_clause, no_leading_underscores_for_local_identifiers
  } on OsrmResponseException catch (_e) {
    rethrow;
    // ignore: unused_catch_clause, no_leading_underscores_for_local_identifiers
  } on Exception catch (_e) {
    rethrow;
  }
}