in lib/server.dart [24:79]
Response _handler(Request request) {
_stopwatch.start();
if (request.requestedUri.pathSegments.length == 1) {
switch (request.requestedUri.pathSegments.single) {
case 'robots.txt':
_robotTxt++;
return Response.ok(
r'''
User-agent: *
Allow: /
''',
);
case '\$info':
_infoRequests++;
final data = {
'since boot': _stopwatch.elapsed.toString(),
'redirects': _redirects,
'notFounds': _notFound,
'info': _infoRequests,
'robot.txt': _robotTxt,
'Dart version': Platform.version,
'request headers': SplayTreeMap.of(request.headers),
};
return Response.ok(
const JsonEncoder.withIndent(' ').convert(data),
headers: {'Content-Type': 'application/json'},
);
case 'favicon.ico':
return Response.ok(
File('static/favicon.ico').readAsBytesSync(),
headers: {'Content-Type': 'image/x-icon'},
);
}
}
final location = findRedirect(request.requestedUri);
if (location != null) {
_redirects++;
return Response.movedPermanently(location);
} else {
_notFound++;
return Response.notFound(
"""
I don't support redirecting path '${request.requestedUri.path}'
Check out my source at https://github.com/dart-lang/dartbug.com
Supported routes:
${routes.map((r) => ' $r').join('\n')}
""",
);
}
}