angel_user_agent 2.0.0
angel_user_agent: ^2.0.0 copied to clipboard

Dart native
Flutter Android iOS

Angel middleware to parse and inject a User Agent object into requests.

example/example.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}');
}
0
likes
90
pub points
0%
popularity

Publisher

angel-dart.dev

Angel middleware to parse and inject a User Agent object into requests.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

angel_framework, user_agent

More

Packages that depend on angel_user_agent