Skip to main content

angel3_user_agent 10.0.0 copy "angel3_user_agent: ^10.0.0" to clipboard
angel3_user_agent: ^10.0.0 copied to clipboard

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

example/example.dart

import 'dart:io';

import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
import 'package:angel3_user_agent/angel3_user_agent.dart';

/// Tells visitors of http://localhost:3000 whether they run Chrome.
void main() async {
  var app = Angel();
  var http = AngelHttp(app);

  app.get(
    '/',
    chain([
      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.loopbackIPv4, 3000);
  print('Listening at http://${server.address.address}:${server.port}');
}
0
likes
150
points
956
downloads

Documentation

API reference

Publisher

verified publisherdukefirehawk.com

Weekly Downloads

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

Homepage
Repository (GitHub)
View/report issues
Contributing

License

BSD-3-Clause (license)

Dependencies

angel3_framework, user_agent_analyzer

More

Packages that depend on angel3_user_agent