handle method

  1. @override
Future<Response> handle(
  1. String serviceName,
  2. RequestMethod method,
  3. String path,
  4. ContentTypeEnum requestContentType,
  5. ContentTypeEnum responseContentType,
  6. bool? login,
  7. dynamic data,
)
override

Implementation

@override
Future<Response> handle(String serviceName, RequestMethod method, String path,
    ContentTypeEnum requestContentType, ContentTypeEnum responseContentType,
    bool? login, dynamic data) async {
  Map<String,String>? headers = {
    'Content-Type': requestContentType.value,
    'Accept': responseContentType.value,
    'Authorization': ''
  };
  final uri = Uri.parse("$HOST/$serviceName/$path");
  if (method == RequestMethod.GET) {
    // final param = encode(data);
    return http.get(uri,headers :headers);
  }else if(method == RequestMethod.POST){
    return http.post(uri,headers :headers,body: jsonEncode(data));
  }
  throw Exception("Unsupported method");
}