README update
This commit is contained in:
parent
6a58fe1cc6
commit
0173d6749f
1 changed files with 10 additions and 15 deletions
25
README.md
25
README.md
|
@ -13,12 +13,13 @@ In your `pubspec.yaml`:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
dependencies:
|
dependencies:
|
||||||
angel_hot: ^1.0.0
|
angel_framework: ^2.0.0-alpha
|
||||||
|
angel_hot: ^2.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
This package is dependent on the Dart VM service, so you *must* run
|
This package is dependent on the Dart VM service, so you *must* run
|
||||||
Dart with the `--enable-vm-service` argument!!!
|
Dart with the `--observe` (or `--enable-vm-service`) argument!!!
|
||||||
|
|
||||||
Usage is fairly simple. Pass a function that creates an `Angel` server, along with a collection of paths
|
Usage is fairly simple. Pass a function that creates an `Angel` server, along with a collection of paths
|
||||||
to watch, to the `HotReloader` constructor. The rest is history!!!
|
to watch, to the `HotReloader` constructor. The rest is history!!!
|
||||||
|
@ -26,7 +27,8 @@ to watch, to the `HotReloader` constructor. The rest is history!!!
|
||||||
The recommended pattern is to only use hot-reloading in your application entry point. Create your `Angel` instance
|
The recommended pattern is to only use hot-reloading in your application entry point. Create your `Angel` instance
|
||||||
within a separate function, conventionally named `createServer`.
|
within a separate function, conventionally named `createServer`.
|
||||||
|
|
||||||
**Using this in production mode is pointless.**
|
**Using this in production mode is not recommended, unless you are
|
||||||
|
specifically intending for a "hot code push" in production..**
|
||||||
|
|
||||||
You can watch:
|
You can watch:
|
||||||
* Files
|
* Files
|
||||||
|
@ -39,8 +41,6 @@ You can watch:
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:angel_compress/angel_compress.dart';
|
|
||||||
import 'package:angel_diagnostics/angel_diagnostics.dart';
|
|
||||||
import 'package:angel_framework/angel_framework.dart';
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
import 'package:angel_hot/angel_hot.dart';
|
import 'package:angel_hot/angel_hot.dart';
|
||||||
import 'src/foo.dart';
|
import 'src/foo.dart';
|
||||||
|
@ -56,28 +56,23 @@ main() async {
|
||||||
Uri.parse('package:angel_hot/angel_hot.dart')
|
Uri.parse('package:angel_hot/angel_hot.dart')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var server = await hot.startServer(InternetAddress.LOOPBACK_IP_V4, 3000);
|
var server = await hot.startServer('127.0.0.1', 3000);
|
||||||
print(
|
print(
|
||||||
'Hot server listening at http://${server.address.address}:${server.port}');
|
'Hot server listening at http://${server.address.address}:${server.port}');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Angel> createServer() async {
|
Future<Angel> createServer() async {
|
||||||
var app = new Angel();
|
var app = new Angel();
|
||||||
|
..injectSerializer(JSON.encode);
|
||||||
|
|
||||||
app.lazyParseBodies = true;
|
app.get('/', (req, res) => {'hello': 'hot world!'});
|
||||||
app.injectSerializer(JSON.encode);
|
|
||||||
|
|
||||||
app.get('/', {'hello': 'hot world!'});
|
|
||||||
|
|
||||||
app.post('/foo/bar', (req, res) async {
|
app.post('/foo/bar', (req, res) async {
|
||||||
var result = await someLengthyOperation();
|
var result = await someLengthyOperation();
|
||||||
return {'status': result};
|
return {'status': result};
|
||||||
});
|
});
|
||||||
|
|
||||||
app.after.add(() => throw new AngelHttpException.notFound());
|
app.fallback((req, res) => throw new AngelHttpException.notFound());
|
||||||
|
|
||||||
app.responseFinalizers.add(gzip());
|
|
||||||
await app.configure(logRequests());
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue