awslabs / aws-lambda-dart-runtime

A Dart runtime for AWS Lambda
https://awslabs.github.io/aws-lambda-dart-runtime/
Apache License 2.0
146 stars 30 forks source link

AwsApiGatewayResponse constructor arguments is all dynamic due to missing type signatures #14

Closed Schwusch closed 4 years ago

Schwusch commented 4 years ago

It is a bit confusing that all constructor parameters is dynamic, when supplying the wrong type will throw a runtime error.

AwsApiGatewayResponse({
    body, 
    isBase64Encoded,
    headers,
    statusCode,
  }) {
    this.body = body ?? '';
    this.isBase64Encoded = isBase64Encoded ?? false;
    this.headers = headers ?? {"Content-Type": "application/json"};
    this.statusCode = statusCode ?? HttpStatus.ok;
  }

It would make the API more friendly and less error prone if the parameters had types:

AwsApiGatewayResponse({
    String body, 
    bool isBase64Encoded,
    Map<String, String> headers,
    int statusCode,
  }) {
    this.body = body ?? '';
    this.isBase64Encoded = isBase64Encoded ?? false;
    this.headers = headers ?? {"Content-Type": "application/json"};
    this.statusCode = statusCode ?? HttpStatus.ok;
  }