makeApiEvent function
Implementation
ApiGatewayEvent makeApiEvent({
String body = '',
bool isBase64Encoded = false,
List<String> cookies = const [],
Map<String, String> headers = const {},
Map<String, String> pathParameters = const {},
Map<String, String> stageVariables = const {},
Map<String, String> queryStringParameters = const {},
}) {
final now = DateTime.now();
final domainPrefix = 'test';
final domainName = 'test.my-great.app';
return ApiGatewayEvent(
version: '2.0',
routeKey: r'$default',
rawPath: '/',
rawQueryString: '',
cookies: cookies,
headers: headers,
queryStringParameters: queryStringParameters,
requestContext: ApiGatewayRequestContext(
accountId: randomId(),
apiId: randomId(6),
authorizer: <String, ApiGatewayAuthorizer>{
'cognito': ApiGatewayAuthorizer(claims: {}, scopes: []),
},
domainName: domainName,
domainPrefix: domainPrefix,
http: <String, String>{
"method": "POST",
"path": "/my/path",
"protocol": "HTTP/1.1",
"sourceIp": "IP",
"userAgent": "agent",
},
requestId: randomId(),
routeKey: r'$default',
stage: 'test',
time: now,
timeEpoch: (now.millisecondsSinceEpoch / 1000).floor(),
),
body: body,
isBase64Encoded: isBase64Encoded,
pathParameters: pathParameters,
stageVariables: stageVariables,
);
}