platform/lib/src/config/routes.dart

21 lines
653 B
Dart
Raw Normal View History

2016-04-22 02:56:21 +00:00
/// This app's route configuration.
library angel.routes;
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_static/angel_static.dart';
/// Put your app routes here!
2016-04-30 00:33:27 +00:00
configureRoutes(Angel app) async {
2016-04-22 02:56:21 +00:00
app.get('/', (req, ResponseContext res) => res.render('hello'));
2016-04-29 01:22:53 +00:00
app.all('*', serveStatic());
2016-04-22 02:56:21 +00:00
2016-04-29 01:22:53 +00:00
// 404 handler
app.after.add((RequestContext req, ResponseContext res) async {
2016-04-22 02:56:21 +00:00
res.willCloseItself = true;
res.status(404);
res.header('Content-Type', 'text/html');
res.underlyingResponse.write(
await app.viewGenerator('404', {'path': req.path}));
await res.underlyingResponse.close();
2016-04-29 01:22:53 +00:00
});
2016-04-22 02:56:21 +00:00
}