HttpApiRequest constructor
HttpApiRequest({})
Implementation
factory HttpApiRequest({
required Uri url,
required String endpoint,
required Map<String, dynamic> params,
RequestContext? context,
Map<String, String>? headers,
ApiCodec? codec,
}) {
String method = 'POST';
var words = CaseStyle.splitWords(endpoint);
if (words.first.toLowerCase() == 'get') {
if (words.length > 1) {
words.removeAt(0);
}
method = 'GET';
}
return HttpApiRequest._(
url: url.replace(
path: url.path + '/' + words.map((w) => w.toLowerCase()).join('_')),
method: method,
headers: headers ?? <String, String>{},
parameters: params,
context: context?.finalize(),
codec: codec,
);
}