A server-side microframework for the Dart platform
import 'package:redstone/redstone.dart' as app;
@app.Route("/")
helloWorld() => "Hello, World!";
main() {
app.setupConsoleLog();
app.start();
}
@app.Interceptor(r'/admin/.*')
adminFilter() {
if (app.request.session["username"] != null) {
return app.chain.next();
} else {
return app.chain.abort(HttpStatus.UNAUTHORIZED);
//or app.redirect("/login.html");
}
}
@app.ErrorHandler(404)
handleNotFoundError() => app.redirect("/error/not_found.html");
main() {
setUp(app.redstoneSetUp);
tearDown(app.redstoneTearDown);
test("service", () {
var req = new MockRequest("/service");
return app.dispatch(req).then((resp) {
expect(resp.statusCode, equals(200));
expect(resp.mockContent, equals("ok"));
});
})
}