diff --git a/frameworks/Dart/dart3/.gitignore b/frameworks/Dart/dart3/.gitignore index 8ac40f21809..27fe9f77a4b 100644 --- a/frameworks/Dart/dart3/.gitignore +++ b/frameworks/Dart/dart3/.gitignore @@ -2,4 +2,4 @@ # Created by `dart pub` .dart_tool/ *.lock -!bin \ No newline at end of file +!bin diff --git a/frameworks/Dart/dart3/bin/server.dart b/frameworks/Dart/dart3/bin/server.dart index f2b98dcd197..5859cc51f82 100755 --- a/frameworks/Dart/dart3/bin/server.dart +++ b/frameworks/Dart/dart3/bin/server.dart @@ -2,24 +2,22 @@ import 'dart:convert'; import 'dart:io'; import 'dart:isolate'; -final _encoder = JsonUtf8Encoder(); - -void main(List _) async { - /// Create an [Isolate] containinig an [HttpServer] +void main(List args) async { + /// Create an [Isolate] containing an [HttpServer] /// for each processor after the first for (var i = 1; i < Platform.numberOfProcessors; i++) { - await Isolate.spawn(_startServer, _); + await Isolate.spawn(_startServer, args); } /// Create a [HttpServer] for the first processor - await _startServer(_); + await _startServer(args); } /// Creates and setup a [HttpServer] Future _startServer(List _) async { /// Binds the [HttpServer] on `0.0.0.0:8080`. final server = await HttpServer.bind( - InternetAddress('0.0.0.0', type: InternetAddressType.IPv4), + InternetAddress.anyIPv4, 8080, shared: true, ); @@ -51,39 +49,35 @@ void _sendResponse( int statusCode, { ContentType? type, List bytes = const [], -}) => - request.response - ..statusCode = statusCode - ..headers.contentType = type - ..headers.date = DateTime.now() - ..contentLength = bytes.length - ..add(bytes) - ..close(); +}) => request.response + ..statusCode = statusCode + ..headers.contentType = type + ..headers.date = DateTime.now() + ..contentLength = bytes.length + ..add(bytes) + ..close(); /// Completes the given [request] by writing the [response] as JSON. void _sendJson(HttpRequest request, Object response) => _sendResponse( - request, - HttpStatus.ok, - type: ContentType.json, - bytes: _encoder.convert(response), - ); + request, + HttpStatus.ok, + type: ContentType.json, + bytes: _jsonEncoder.convert(response), +); /// Completes the given [request] by writing the [response] as plain text. void _sendText(HttpRequest request, String response) => _sendResponse( - request, - HttpStatus.ok, - type: ContentType.text, - bytes: utf8.encode(response), - ); + request, + HttpStatus.ok, + type: ContentType.text, + bytes: utf8.encode(response), +); /// Responds with the JSON test to the [request]. -void _jsonTest(HttpRequest request) => _sendJson( - request, - const {'message': 'Hello, World!'}, - ); +void _jsonTest(HttpRequest request) => + _sendJson(request, const {'message': 'Hello, World!'}); /// Responds with the plaintext test to the [request]. -void _plaintextTest(HttpRequest request) => _sendText( - request, - 'Hello, World!', - ); +void _plaintextTest(HttpRequest request) => _sendText(request, 'Hello, World!'); + +final _jsonEncoder = JsonUtf8Encoder(); diff --git a/frameworks/Dart/dart3/dart3.dockerfile b/frameworks/Dart/dart3/dart3.dockerfile index 7e6e9053968..812b7e959ee 100644 --- a/frameworks/Dart/dart3/dart3.dockerfile +++ b/frameworks/Dart/dart3/dart3.dockerfile @@ -1,5 +1,5 @@ -FROM dart:3.5 AS builder +FROM dart:3.8 AS builder COPY . /app WORKDIR /app @@ -11,4 +11,4 @@ COPY --from=builder /runtime/ / COPY --from=builder /app/build /bin EXPOSE 8080 -CMD ["server"] \ No newline at end of file +CMD ["server"] diff --git a/frameworks/Dart/dart3/pubspec.yaml b/frameworks/Dart/dart3/pubspec.yaml index 2b351720c9b..5a99e258055 100644 --- a/frameworks/Dart/dart3/pubspec.yaml +++ b/frameworks/Dart/dart3/pubspec.yaml @@ -1,7 +1,7 @@ name: dartbenchmark description: A benchmark of dart environment: - sdk: '>=3.5.0 <4.0.0' + sdk: ^3.8.0 dev_dependencies: lints: ^4.0.0