call method

Future<Response> call()

Implementation

Future<Response> call() async {
  Uri url;
  if (ssl) {
    url = Uri.https(baseUrl, route, queryParams);
  } else {
    url = Uri.http(baseUrl, route, queryParams);
  }
  try {
    if (method == "GET") {
      return await get(url);
    } else if (method == "POST") {
      return await post(url);
    } else if (method == "PUT") {
      return await put(url);
    } else if (method == "DELETE") {
      return await delete(url);
    } else {
      throw Exception("Invalid Method");
      // return await get(url);
    }
  } on SocketException {
    return Response(502, "502 Bad Gateway", '{"status": "502 Bad Gateway"}',
        "502 Bad Gateway");
  } catch (e) {
    return Response(
        500,
        "500 Internal Server Error ${e.toString()}",
        '{"status": "500 Internal Server Error ${e.toString()}"}',
        '{"status": "500 Internal Server Error ${e.toString()}"}');
  }
}