platform/packages/user_agent/example/example.dart
Tobe O a5f5661650 Add 'packages/user_agent/' from commit '70b15207d5e746fca954c5c7107ad8e1be059078'
git-subtree-dir: packages/user_agent
git-subtree-mainline: ae8f7a77d2
git-subtree-split: 70b15207d5
2020-02-15 18:29:14 -05:00

25 lines
675 B
Dart

import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_user_agent/angel_user_agent.dart';
import 'package:user_agent/user_agent.dart';
main() async {
var app = new Angel();
var http = new AngelHttp(app);
app.get(
'/',
waterfall([
parseUserAgent,
(req, res) {
var ua = req.container.make<UserAgent>();
return ua.isChrome
? 'Woohoo! You are running Chrome.'
: 'Sorry, we only support Google Chrome.';
},
]),
);
var server = await http.startServer(InternetAddress.anyIPv4, 3000);
print('Listening at http://${server.address.address}:${server.port}');
}