diff --git a/README.md b/README.md index da3830ad..958d9892 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,17 @@ main() async { } ``` +# Push State Example +```dart +var vDir = new VirtualDirectory(...); +var indexFile = new File.fromUri(vDir.source.uri.resolve('index.html')); + +app.after.add((req, ResponseContext res) { + // Fallback to index.html on 404 + return res.sendFile(indexFile); +}); +``` + # Options The `VirtualDirectory` API accepts a few named parameters: - **source**: A `Directory` containing the files to be served. If left null, then Angel will serve either from `web` (in development) or @@ -46,4 +57,4 @@ The `VirtualDirectory` API accepts a few named parameters: - **debug**: Print verbose debug output. - **callback**: Runs before sending a file to a client. Use this to set headers, etc. If it returns anything other than `null` or `true`, then the callback's result will be sent to the user, instead of the file contents. -- **streamToIO**: If set to `true`, files will be streamed to `res.io`, instead of added to `res.buffer`.. Default is `false`. \ No newline at end of file +- **streamToIO**: If set to `true`, files will be streamed to `res.io`, instead of added to `res.buffer`.. Default is `false`.