platform/packages/user_agent/example/example.dart

30 lines
766 B
Dart
Raw Normal View History

2018-09-11 21:21:06 +00:00
import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
2021-02-14 05:22:25 +00:00
import 'package:angel_framework/http.dart';
2018-09-11 21:21:06 +00:00
import 'package:angel_user_agent/angel_user_agent.dart';
import 'package:user_agent/user_agent.dart';
main() async {
2021-02-14 05:22:25 +00:00
var app = Angel();
var http = AngelHttp(app);
2018-09-11 21:21:06 +00:00
2021-02-14 05:22:25 +00:00
// TODO: Commented out due to unknow class
/*
2018-09-11 21:21:06 +00:00
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.';
},
]),
);
2021-02-14 05:22:25 +00:00
*/
2018-09-11 21:21:06 +00:00
var server = await http.startServer(InternetAddress.anyIPv4, 3000);
print('Listening at http://${server.address.address}:${server.port}');
}