diff --git a/example/rate_limit.dart b/example/rate_limit.dart index e211a310..8b33d5a7 100644 --- a/example/rate_limit.dart +++ b/example/rate_limit.dart @@ -1,10 +1,15 @@ import 'package:angel_framework/angel_framework.dart'; import 'package:angel_framework/http.dart'; import 'package:angel_security/angel_security.dart'; +import 'package:logging/logging.dart'; +import 'package:pretty_logging/pretty_logging.dart'; main() async { + // Logging boilerplate. + Logger.root.onRecord.listen(prettyLog); + // Create an app, and HTTP driver. - var app = Angel(), http = AngelHttp(app); + var app = Angel(logger: Logger('rate_limit')), http = AngelHttp(app); // Create a simple in-memory rate limiter that limits users to 5 // queries per hour. diff --git a/lib/src/rate_limiter.dart b/lib/src/rate_limiter.dart index ea5a7d0f..36477ebf 100644 --- a/lib/src/rate_limiter.dart +++ b/lib/src/rate_limiter.dart @@ -26,7 +26,7 @@ abstract class RateLimiter { final String errorMessage; RateLimiter(this.maxPointsPerWindow, this.windowDuration, - {this.errorMessage}); + {this.errorMessage = 'Rate limit exceeded.'}); /// Computes the current window in which the user is acting. /// diff --git a/pubspec.yaml b/pubspec.yaml index 87054460..cbde50fa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,4 +12,5 @@ dev_dependencies: angel_test: ^2.0.0 angel_validate: ^2.0.0 pedantic: ^1.0.0 + pretty_logging: ^1.0.0 test: ^1.0.0