Comparing version 0.3.0 to 0.3.1
15
index.js
@@ -9,8 +9,9 @@ var Rocky = require('./lib/rocky') | ||
rocky.Rocky = Rocky | ||
rocky.Base = require('./lib/base') | ||
rocky.Route = require('./lib/route') | ||
rocky.Dispatcher = require('./lib/dispatcher') | ||
rocky.middleware = require('./lib/middleware') | ||
rocky.httpProxy = require('http-proxy') | ||
rocky.VERSION = require('./package.json').version | ||
rocky.Rocky = Rocky | ||
rocky.Base = require('./lib/base') | ||
rocky.Route = require('./lib/route') | ||
rocky.Dispatcher = require('./lib/dispatcher') | ||
rocky.middleware = require('./lib/middleware') | ||
rocky.passthrough = require('./lib/passthrough') | ||
rocky.httpProxy = require('http-proxy') | ||
rocky.VERSION = require('./package.json').version |
@@ -1,6 +0,4 @@ | ||
const _ = require('lodash') | ||
const errors = require('./errors') | ||
const replay = require('./passes/replay') | ||
const forward = require('./passes/forward') | ||
const parseUrl = require('url').parse | ||
const _ = require('lodash') | ||
const errors = require('./errors') | ||
const passthrough = require('./passthrough') | ||
@@ -22,3 +20,3 @@ module.exports = Dispatcher | ||
Dispatcher.prototype.dispatch = function (req, res) { | ||
Dispatcher.prototype.dispatch = function (req, res, next) { | ||
var route = this.route | ||
@@ -42,5 +40,5 @@ var opts = this.options() | ||
if (opts.replayAfterForward) { | ||
this.dispatchSequentially(opts, req, res) | ||
this.dispatchSequentially(opts, req, res, next) | ||
} else { | ||
this.dispatchConcurrently(opts, req, res) | ||
this.dispatchConcurrently(opts, req, res, next) | ||
} | ||
@@ -50,23 +48,10 @@ } | ||
Dispatcher.prototype.dispatchConcurrently = function (opts, req, res) { | ||
this.forward(opts, req, res) | ||
this.replay(opts, req) | ||
Dispatcher.prototype.dispatchConcurrently = function (opts, req, res, next) { | ||
var args = [ this.route, opts, req, res ] | ||
passthrough.concurrently(args, next) | ||
} | ||
Dispatcher.prototype.dispatchSequentially = function (opts, req, res) { | ||
this.forward(opts, req, res, replay.bind(this)) | ||
function replay(err, res) { | ||
if (!err && res && res.statusCode < 500) { | ||
this.replay(opts, req) | ||
} | ||
} | ||
Dispatcher.prototype.dispatchSequentially = function (opts, req, res, next) { | ||
var args = [ this.route, opts, req, res ] | ||
passthrough.sequentially(args, next) | ||
} | ||
Dispatcher.prototype.forward = function (opts, req, res, next) { | ||
forward(this.route, opts, req, res, next) | ||
} | ||
Dispatcher.prototype.replay = function (opts, req) { | ||
replay(this.route, req, opts) | ||
} |
@@ -10,3 +10,3 @@ const http = require('http') | ||
module.exports = function replay(route, req, opts) { | ||
module.exports = function replay(route, opts, req, res, next) { | ||
var replays = route.replays && route.replays.length | ||
@@ -19,10 +19,12 @@ ? route.replays | ||
replayStrategy(targets, opts, replayer) | ||
next = next || function () {} | ||
replayStrategy(targets, opts, replayer, next) | ||
} | ||
function replayStrategy(replays, opts, replayer) { | ||
function replayStrategy(replays, opts, replayer, done) { | ||
if (opts.replaySequentially) { | ||
common.eachSeries(replays, replayer) | ||
common.eachSeries(replays, replayer, done) | ||
} else { | ||
replays.forEach(replayer) | ||
done() | ||
} | ||
@@ -29,0 +31,0 @@ } |
{ | ||
"name": "rocky", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Featured, middleware-oriented HTTP/S proxy with traffic replay and intercept", | ||
@@ -5,0 +5,0 @@ "repository": "h2non/rocky", |
@@ -947,2 +947,8 @@ # rocky [![Build Status](https://api.travis-ci.org/h2non/rocky.svg?branch=master&style=flat)](https://travis-ci.org/h2non/rocky) [![Code Climate](https://codeclimate.com/github/h2non/rocky/badges/gpa.svg)](https://codeclimate.com/github/h2non/rocky) [![NPM](https://img.shields.io/npm/v/rocky.svg)](https://www.npmjs.org/package/rocky) ![Downloads](https://img.shields.io/npm/dm/rocky.svg) | ||
### rocky.passthrough | ||
Accessor for the [passthrough](https://github.com/h2non/rocky/blob/master/lib/passthrough.js) module | ||
For hacking purposes, you can add additional HTTP traffic passthrough phases pushing the pass `function` via `passthrough.passes.push()` | ||
### rocky.httpProxy | ||
@@ -949,0 +955,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130583
70
3007
971
29