buildRequest function

Request buildRequest(
  1. String method,
  2. String path, {
  3. Map<String, String> headers = const {},
  4. Object? body,
  5. Map<String, String> pathParameters = const {},
  6. Map<String, Object> context = const {},
})

Builds a shelf Request for testing extractors without a router.

Implementation

Request buildRequest(
  String method,
  String path, {
  Map<String, String> headers = const {},
  Object? body,
  Map<String, String> pathParameters = const {},
  Map<String, Object> context = const {},
}) {
  return Request(
    method,
    Uri.parse('http://localhost$path'),
    headers: headers,
    body: body,
    context: {
      if (pathParameters.isNotEmpty) pathParametersKey: pathParameters,
      ...context,
    },
  );
}