platform/lib/src/routes/routes.dart

33 lines
882 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';
2016-07-05 21:11:54 +00:00
import 'controllers/controllers.dart' as Controllers;
2016-04-22 02:56:21 +00:00
2016-06-23 21:54:10 +00:00
configureBefore(Angel app) async {}
2016-04-22 02:56:21 +00:00
/// 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-11-23 22:21:41 +00:00
app.all('*', new VirtualDirectory());
2016-06-23 21:54:10 +00:00
}
2016-04-22 02:56:21 +00:00
2016-06-23 21:54:10 +00:00
configureAfter(Angel app) async {
2016-04-29 01:22:53 +00:00
// 404 handler
2016-09-21 06:50:44 +00:00
app.after.add((req, ResponseContext res) async {
throw new AngelHttpException.NotFound();
});
2016-09-21 05:44:56 +00:00
// Default error handler
app.onError(
(e, req, res) async => res.render("error", {"message": e.message}));
2016-06-23 21:54:10 +00:00
}
configureServer(Angel app) async {
await configureBefore(app);
await configureRoutes(app);
2016-09-21 05:44:56 +00:00
await app.configure(Controllers.configureServer);
2016-06-23 21:54:10 +00:00
await configureAfter(app);
}