angel_hot 2.0.2 copy "angel_hot: ^2.0.2" to clipboard
angel_hot: ^2.0.2 copied to clipboard

outdated

Supports hot reloading/hot code push of Angel servers on file changes.

example/main.dart

import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_hot/angel_hot.dart';
import 'package:logging/logging.dart';
import 'src/foo.dart';

main() async {
  var hot = new HotReloader(createServer, [
    new Directory('src'),
    new Directory('src'),
    'main.dart',
    Uri.parse('package:angel_hot/angel_hot.dart')
  ]);
  await hot.startServer('127.0.0.1', 3000);
}

Future<Angel> createServer() async {
  var app = new Angel()..serializer = json.encode;

  // Edit this line, and then refresh the page in your browser!
  app.get('/', (req, res) => {'hello': 'hot world!'});
  app.get('/foo', (req, res) => new Foo(bar: 'baz'));

  app.fallback((req, res) => throw new AngelHttpException.notFound());

  app.encoders.addAll({
    'gzip': gzip.encoder,
    'deflate': zlib.encoder,
  });

  app.logger = new Logger('angel')
    ..onRecord.listen((rec) {
      print(rec);
      if (rec.error != null) {
        print(rec.error);
        print(rec.stackTrace);
      }
    });

  return app;
}
4
likes
0
pub points
0%
popularity

Publisher

verified publisherangel-dart.dev

Supports hot reloading/hot code push of Angel servers on file changes.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

angel_framework, angel_websocket, charcode, glob, html_builder, io, vm_service_lib, watcher

More

Packages that depend on angel_hot