handle method
Future<Response>
handle(
- String serviceName,
- RequestMethod method,
- String path,
- ContentTypeEnum requestContentType,
- ContentTypeEnum responseContentType,
- bool? login,
- 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");
}