jaguar_dev_proxy 2.4.4

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 68

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 run build_runner serve web:8000
  final proxy = PrefixedProxyServer('/client', 'http://localhost:8000/');

  final server = Jaguar(address: 'localhost', port: 8085);
  server.add(proxy);
  server.getJson('/api/user', (Context ctx) => {'name': 'teja'});
  server.log.onRecord.listen(print);
  await server.serve(logRequests: true);
}

Changelog #

33 2.1.4

  • Dart 2 stable

2.1.2 #

  • before and after interceptors

Use this package as a library

1. Depend on it

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


dependencies:
  jaguar_dev_proxy: ^2.4.4

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 flutter 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
2.4.4 Dec 28, 2018 Go to the documentation of jaguar_dev_proxy 2.4.4 Download jaguar_dev_proxy 2.4.4 archive
2.4.2 Dec 27, 2018 Go to the documentation of jaguar_dev_proxy 2.4.2 Download jaguar_dev_proxy 2.4.2 archive
2.4.1 Sep 18, 2018 Go to the documentation of jaguar_dev_proxy 2.4.1 Download jaguar_dev_proxy 2.4.1 archive
2.2.0 Aug 14, 2018 Go to the documentation of jaguar_dev_proxy 2.2.0 Download jaguar_dev_proxy 2.2.0 archive
2.1.8 Aug 7, 2018 Go to the documentation of jaguar_dev_proxy 2.1.8 Download jaguar_dev_proxy 2.1.8 archive
2.1.6 Aug 7, 2018 Go to the documentation of jaguar_dev_proxy 2.1.6 Download jaguar_dev_proxy 2.1.6 archive
2.1.5 Aug 7, 2018 Go to the documentation of jaguar_dev_proxy 2.1.5 Download jaguar_dev_proxy 2.1.5 archive
2.1.4 Aug 7, 2018 Go to the documentation of jaguar_dev_proxy 2.1.4 Download jaguar_dev_proxy 2.1.4 archive
2.1.2 Aug 7, 2018 Go to the documentation of jaguar_dev_proxy 2.1.2 Download jaguar_dev_proxy 2.1.2 archive
2.1.1 May 20, 2018 Go to the documentation of jaguar_dev_proxy 2.1.1 Download jaguar_dev_proxy 2.1.1 archive

All 19 versions...

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

We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13

Platforms

Detected platforms: Flutter, other

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

Health suggestions

Fix lib/jaguar_dev_proxy.dart. (-1 points)

Analysis of lib/jaguar_dev_proxy.dart reported 2 hints:

line 43 col 21: Use = to separate a named parameter from its default value.

line 44 col 21: Use = to separate a named parameter from its default value.

Maintenance suggestions

The package description is too short. (-17 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and jaguar_dev_proxy.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.65 <3.0.0
jaguar ^2.4.14 2.4.26
path ^1.6.2 1.6.2
Transitive dependencies
auth_header 2.1.2
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
http_server 0.9.8+1
jaguar_common 2.1.4
jaguar_serializer 2.2.8
logging 0.11.3+2
meta 1.1.7
mime 0.9.6+2
path_tree 2.2.2
stack_trace 1.9.3
typed_data 1.1.6
Dev dependencies
build_runner ^0.10.0
build_web_compilers ^0.4.1
test ^1.3.0