platform/packages/static/test/cache_sample.dart
Tobe O f7c6ebf200 Add 'packages/static/' from commit '6ec67dde7bd318c5e82fce66e3b22dfa3a378c24'
git-subtree-dir: packages/static
git-subtree-mainline: 17ad5f82c3
git-subtree-split: 6ec67dde7b
2020-02-15 18:21:58 -05:00

28 lines
771 B
Dart

import 'package:angel_framework/angel_framework.dart';
import 'package:angel_framework/http.dart';
import 'package:angel_static/angel_static.dart';
import 'package:file/file.dart';
import 'package:file/local.dart';
main() async {
Angel app;
AngelHttp http;
Directory testDir = const LocalFileSystem().directory('test');
app = Angel();
http = AngelHttp(app);
app.fallback(
CachingVirtualDirectory(app, const LocalFileSystem(),
source: testDir,
maxAge: 350,
onlyInProduction: false,
indexFileNames: ['index.txt']).handleRequest,
);
app.get('*', (req, res) => 'Fallback');
app.dumpTree(showMatchers: true);
var server = await http.startServer();
print('Open at http://${server.address.host}:${server.port}');
}