jaguar_dev_proxy 1.3.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 73

jaguar_dev_proxy

Provides PrefixedProxyServer to reverse proxy certain selected requests to another server.

This is similar to Nginx's reverse proxy.

Usage

An instance of PrefixedProxyServer has to be created and added to a Jaguar server. The constructor of PrefixedProxyServer takes all the necessary parameters to configure the reverse proxy.

The job of the reverse proxy is to

  1. Match certain paths
  2. Transform it to a target path
  3. Forward the received request to the target path
  4. Forward the response obtained from server to the client

Step 1 and 2 requires configuration.

The matched path

The first parameter (path) to the constructor is used to match the incoming URL/route. The matching is based on prefix. For example:

When path is /html, it will match:

  • /html
  • /html/
  • /html/index.html
  • /html/static/index.html

Target path

The second parameter (proxyBaseUrl) is used to transform the incoming request URL to reverse proxy target URL. The proxyBaseUrl is just prefixed to the remaining part after path is matched match. For example:

For new PrefixedProxyServer('/html', 'http://localhost:8000/client'),

  • /html is mapped into http://localhost:8000/client/
  • /html/ is mapped into http://localhost:8000/client/
  • /html/index.html is mapped into http://localhost:8000/client/index.html
  • /html/static/index.html is mapped into http://localhost:8000/client/static/index.html

Boilerplate

The boilerplate example to showcasing reverse proxy capabilities of Jaguar can be found at Reverse proxy example.

Simple example

A simple usage example:

import 'package:jaguar/jaguar.dart';
import 'package:jaguar_dev_proxy/jaguar_dev_proxy.dart';

main() async {
  // Proxy all html client requests to pub server
  // NOTE: Run pub server on port 8000 using command
  //     pub serve --port 8000
  final proxy = new PrefixedProxyServer('/client', 'http://localhost:8000/');

  final server = new Jaguar(address: 'localhost', port: 8085);
  server.addApi(proxy);
  server.get(
      '/api/user',
      (Context ctx) => Response.json({
            'name': 'teja',
          }));
  server.get('/client/version', (Context ctx) => '0.1');
  await server.serve();
}

Changelog

0.0.6

  • Added docs
  • Updated README

0.0.1

  • Initial version, created by Stagehand

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  jaguar_dev_proxy: "^1.3.1"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:jaguar_dev_proxy/jaguar_dev_proxy.dart';
        
Version Uploaded Documentation Archive
1.3.1 Feb 2, 2018 Go to the documentation of jaguar_dev_proxy 1.3.1 Download jaguar_dev_proxy 1.3.1 archive
1.2.6 Jan 13, 2018 Go to the documentation of jaguar_dev_proxy 1.2.6 Download jaguar_dev_proxy 1.2.6 archive
1.1.5 Jan 11, 2018 Go to the documentation of jaguar_dev_proxy 1.1.5 Download jaguar_dev_proxy 1.1.5 archive
0.0.6 Dec 20, 2017 Go to the documentation of jaguar_dev_proxy 0.0.6 Download jaguar_dev_proxy 0.0.6 archive
0.0.5 Jul 10, 2017 Go to the documentation of jaguar_dev_proxy 0.0.5 Download jaguar_dev_proxy 0.0.5 archive
0.0.4 Jun 7, 2017 Go to the documentation of jaguar_dev_proxy 0.0.4 Download jaguar_dev_proxy 0.0.4 archive
0.0.3 Feb 19, 2017 Go to the documentation of jaguar_dev_proxy 0.0.3 Download jaguar_dev_proxy 0.0.3 archive
0.0.2 Feb 7, 2017 Go to the documentation of jaguar_dev_proxy 0.0.2 Download jaguar_dev_proxy 0.0.2 archive
0.0.1 Feb 7, 2017 Go to the documentation of jaguar_dev_proxy 0.0.1 Download jaguar_dev_proxy 0.0.1 archive

Analysis

We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
47 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
73
Learn more about scoring.

Platforms

Detected platforms: Flutter, other

Primary library: package:jaguar_dev_proxy/jaguar_dev_proxy.dart with components: io.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use jaguar_dev_proxy.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
jaguar ^1.3.4 1.3.11
path >=0.9.0 <2.0.0 1.5.1
Transitive dependencies
args 1.4.2
charcode 1.1.1
collection 1.14.9
convert 2.0.1
crypto 2.0.2+1
http_server 0.9.7
logging 0.11.3+1
meta 1.1.2
mime 0.9.6
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
typed_data 1.1.5
yaml 2.1.13
Dev dependencies
test >=0.12.0 <0.13.0