Proxy HTTP requests to other server (typically from Dart backend to pub serve during development).
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
.analysis_options
.gitignore
LICENSE
README.md
pubspec.yaml

README.md

HTTP request proxy

Proxy HTTP requests to other server (typically from Dart backend to pub serve during development).

Usage

A simple usage example:

import 'dart:io';
import 'package:http_request_proxy/http_request_proxy.dart';

main() {
  var proxy = new HttpRequestProxy('localhost', 8000);
  HttpServer server = await HttpServer.bind(InternetAddress.ANY_IP_V4, 3333);
  server.listen((request) {
    if (request.uri.path.startsWith('/api/')) {
      // handle API call
    } else {
      // proxy to local pub serve
      proxy.proxyHttpRequest(request);
    }
  });
}

Links