From a39ee0779a751d2331d4885a3589040b48ab6db7 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Thu, 1 Dec 2016 17:40:23 -0500 Subject: [PATCH] Update README.md --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index d790fca9..c2f4bba3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,34 @@ # shelf Shelf interop with Angel. Will be deprecated by v2.0.0. + +By version 2 of Angel, I will migrate the server to run on top of `shelf`. +Until then, use the code in this repo to embed existing shelf apps into +your Angel applications. + +This will make it easy to layer your API over a production application, +rather than having to port code. + +```dart +import 'dart:io'; +import 'package:angel_framework/angel_framework.dart'; +import 'package:angel_shelf/angel_shelf.dart'; +import 'package:shelf/shelf.dart' as shelf; +import 'api/api.dart'; + +main() async { + final app = new Angel(); + + // Angel routes on top + await app.configure(new ApiController()); + + // Re-route all other traffic to an + // existing shelf/Redstone application. + app.mount('/', embedShelf( + shelf.Pipeline() + .addMiddleware(shelf.logRequests()) + .addHandler(_echoRequest) + )); + + await app.startServer(InternetAddress.LOOPBACK_IP_V4, 3000); +} +```