@@ -15,34 +15,34 @@ final _router = Router()
1515 ..post ('/logs/<path>' , _post);
1616
1717Future <Response > _delete (Request req) async {
18- var file = File ('$rootDir /deleteMe.log' );
18+ final file = File ('$rootDir /deleteMe.log' );
1919 if (file.existsSync ()) {
2020 await file.delete ();
2121 }
2222 return Response .ok (null );
2323}
2424
2525Future <Response > _get (Request req, String path) async {
26- var file = File ('$rootDir /$path ' );
26+ final file = File ('$rootDir /$path ' );
2727 if (! file.existsSync ()) {
2828 return Response .notFound (null );
2929 }
30- var body = file.readAsStringSync ();
30+ final body = file.readAsStringSync ();
3131 return Response .ok (body);
3232}
3333
3434Future <Response > _head (Request req, String path) async {
35- var file = File ('$rootDir /$path ' );
35+ final file = File ('$rootDir /$path ' );
3636 if (! file.existsSync ()) {
3737 return Response .notFound (null );
3838 }
39- var length = file.lengthSync ();
39+ final length = file.lengthSync ();
4040 return Response .ok (null , headers: {'content-length' : '$length ' });
4141}
4242
4343Future <Response > _post (Request req, String path) async {
4444 // validate received data
45- var mimeType = req.mimeType;
45+ final mimeType = req.mimeType;
4646 if (mimeType != 'text/plain' ) {
4747 return Response .badRequest (body: 'Content-Type must be text/plain!' );
4848 }
@@ -51,12 +51,13 @@ Future<Response> _post(Request req, String path) async {
5151 }
5252
5353 // get body
54- var length = req.contentLength;
55- var body = await req.readAsString ();
54+ final length = req.contentLength;
55+ final body = await req.readAsString ();
5656 if (length != body.length) {
5757 return Response .badRequest (
58- body: 'Content-Length of $length '
59- 'did not match body.length of ${body .length }!' );
58+ body: 'Content-Length of $length '
59+ 'did not match body.length of ${body .length }!' ,
60+ );
6061 }
6162
6263 // // get remote address
@@ -65,7 +66,7 @@ Future<Response> _post(Request req, String path) async {
6566 // var remoteAddress = connectionInfo.remoteAddress.address;
6667 // print('remoteAddress = "$remoteAddress" (${remoteAddress.runtimeType})');
6768
68- var file = File ('$rootDir /$path ' );
69+ final file = File ('$rootDir /$path ' );
6970 file.createSync (exclusive: false );
7071 file.writeAsStringSync (
7172 body,
@@ -75,7 +76,7 @@ Future<Response> _post(Request req, String path) async {
7576}
7677
7778void main (List <String > args) async {
78- Directory (rootDir).create (recursive: true );
79+ await Directory (rootDir).create (recursive: true );
7980
8081 // Use any available host or container IP (usually `0.0.0.0`).
8182 final ip = InternetAddress .anyIPv4;
0 commit comments