The Protevus Platform: Unified Full-Stack Development https://protevus.com
Find a file
2019-05-02 19:19:30 -04:00
.idea 1.1.0-alpha 2017-09-24 14:49:18 -04:00
.vscode 1.0.8 2017-06-20 15:31:35 -04:00
example Bump to 2.1.2 2019-05-02 19:19:30 -04:00
lib Bump to 2.1.2 2019-05-02 19:19:30 -04:00
test Bump to 2.1.2 2019-05-02 19:19:30 -04:00
.gitignore ignore .dart_tool 2018-03-20 14:04:23 -04:00
.travis.yml Works 2016-11-23 17:03:06 -05:00
analysis_options.yaml Bump to 2.1.2 2019-05-02 19:19:30 -04:00
CHANGELOG.md Bump to 2.1.2 2019-05-02 19:19:30 -04:00
LICENSE Initial commit 2016-11-09 23:28:11 -05:00
pubspec.yaml Bump to 2.1.2 2019-05-02 19:19:30 -04:00
README.md 2.1.1 2018-12-09 17:39:11 -05:00

proxy

Pub build status

Angel middleware to forward requests to another server (i.e. webdev serve). Also supports WebSockets.

import 'package:angel_proxy/angel_proxy.dart';
import 'package:http/http.dart' as http;

main() async {
  // ...
  
  var client = http.Client();
  
  // Forward requests instead of serving statically
  var proxy1 = Proxy(client, Uri.parse('http://localhost:3000'));
  
  // handle all methods (GET, POST, ...)
  app.fallback(proxy.handleRequest);
}

You can also restrict the proxy to serving only from a specific root:

Proxy(client, baseUrl, publicPath: '/remote');

Also, you can map requests to a root path on the remote server:

Proxy(client, baseUrl.replace(path: '/path'));

Request bodies will be forwarded as well, if they are not empty. This allows things like POST requests to function.

For a request body to be forwarded, the body must not have already been parsed.