getHttpMethod function
Returns HttpMethod instance for method
parameter.
Implementation
HttpMethod? getHttpMethod(String? method, [HttpMethod? def]) {
if (method == null) return def;
method = method.trim().toUpperCase();
if (method.isEmpty) return def;
switch (method) {
case 'GET':
return HttpMethod.GET;
case 'OPTIONS':
return HttpMethod.OPTIONS;
case 'POST':
return HttpMethod.POST;
case 'PUT':
return HttpMethod.PUT;
case 'DELETE':
return HttpMethod.DELETE;
case 'PATCH':
return HttpMethod.PATCH;
case 'HEAD':
return HttpMethod.HEAD;
default:
return def;
}
}