platform/test/cache_sample.dart

28 lines
720 B
Dart
Raw Normal View History

2017-02-27 00:19:34 +00:00
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_static/angel_static.dart';
2017-09-23 21:57:54 +00:00
import 'package:file/file.dart';
import 'package:file/local.dart';
2017-02-27 00:19:34 +00:00
main() async {
Angel app;
AngelHttp http;
2017-09-23 21:57:54 +00:00
Directory testDir = const LocalFileSystem().directory('test');
app = new Angel();
http = new AngelHttp(app);
2017-02-27 00:19:34 +00:00
2017-09-23 21:57:54 +00:00
app.use(
new CachingVirtualDirectory(app, const LocalFileSystem(),
source: testDir,
maxAge: 350,
onlyInProduction: false,
indexFileNames: ['index.txt']).handleRequest,
);
2017-02-27 00:19:34 +00:00
app.get('*', 'Fallback');
app.dumpTree(showMatchers: true);
var server = await http.startServer();
2017-09-23 21:57:54 +00:00
print('Open at http://${server.address.host}:${server.port}');
2017-02-27 00:19:34 +00:00
}