Comparing version 0.3.0-beta.0 to 0.3.0-beta.1
exports.replyWithError = function (err, res) { | ||
if (res.headersSent) return | ||
if (res.headersSent) return err | ||
@@ -4,0 +4,0 @@ var status = +err.status || 502 |
@@ -33,7 +33,3 @@ const common = require('../common') | ||
if (opts.retry) { | ||
proxyRetryRequest(route, opts, forwardReq, res, resolver) | ||
} else { | ||
proxyRequest(route, opts, forwardReq, res, resolver) | ||
} | ||
forwardStrategy(route, opts, forwardReq, res, resolver) | ||
} | ||
@@ -52,2 +48,10 @@ | ||
function forwardStrategy(route, opts, req, res, resolver) { | ||
if (opts.retry) { | ||
proxyRetryRequest(route, opts, req, res, resolver) | ||
} else { | ||
proxyRequest(route, opts, req, res, resolver) | ||
} | ||
} | ||
function proxyRetryRequest(route, opts, forwardReq, res, resolver) { | ||
@@ -54,0 +58,0 @@ function task(cb) { |
@@ -7,3 +7,3 @@ const retry = require('retry') | ||
// Overwrite methods | ||
// Overwrite response methods | ||
var _writeHead = res.writeHead | ||
@@ -10,0 +10,0 @@ var _end = res.end |
const router = require('router') | ||
const Route = require('./route') | ||
const Base = require('./base') | ||
const createServer = require('./server') | ||
const routeHandler = require('./handler') | ||
const createServer = require('./http/server') | ||
const assign = require('lodash').assign | ||
@@ -7,0 +7,0 @@ const MwPool = require('./mwpool') |
{ | ||
"name": "rocky", | ||
"version": "0.3.0-beta.0", | ||
"version": "0.3.0-beta.1", | ||
"description": "Featured, middleware-oriented HTTP/S proxy with traffic replay and intercept", | ||
@@ -5,0 +5,0 @@ "repository": "h2non/rocky", |
@@ -5,3 +5,3 @@ # 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) | ||
**Pluggable**, **full featured** and **middleware-oriented** **HTTP/S proxy** with versatile **routing** layer, **traffic interceptor and replay** to multiple backends, **built-in balancer**, **hierarchical configuration** and [more](#features). | ||
**Pluggable**, **full featured** and **middleware-oriented** **HTTP/S proxy** with a versatile **routing layer**, **traffic interceptor and replay** to multiple backends, **built-in balancer**, **hierarchical configuration**, traffic **retry/backoff** logic and [more](#features). | ||
Built for [node.js](http://nodejs.org)/[io.js](https://iojs.org). | ||
@@ -65,3 +65,3 @@ Compatible with [connect](https://github.com/senchalabs/connect)/[express](http://expressjs.com). | ||
## When `rocky` could be useful? | ||
## When `rocky` can be useful? | ||
@@ -111,12 +111,13 @@ - As HTTP proxy for service migrations (e.g: APIs) | ||
rocky is relative young but production focused package. | ||
Version `0.1.x` was wrote during my free time in less than 10 days (mostly at night during the weekend), therefore it could be considered in `beta` stage. | ||
rocky is relative young, but production focused project actively maintained and improved. | ||
Version `0.1.x` was wrote during my free time in less than 10 days (mostly at night during the weekend), therefore it can be considered in `beta` stage. | ||
Version `0.2.x` introduced significant improvements such as a more consistent API and a new hierarchical middleware layer. | ||
This version is focused on stability and production use, however it's only recommended to use it in non-hostile environments for now. | ||
`0.3.x` and higher versions are production-focused. API consistency is guaranteed between patch releases. | ||
### Versions | ||
- [**0.1.x**](https://github.com/h2non/rocky/tree/v0.1.x) - First version. Initially released at `25.06.2015`. Beta | ||
- [**0.2.x**](https://github.com/h2non/rocky/tree/v0.2.x) - Released at `07.07.2015`. Pre-production version. | ||
- [**0.2.x**](https://github.com/h2non/rocky/tree/v0.2.x) - Released at `07.07.2015`. | ||
- [**0.3.x**](https://github.com/h2non/rocky/tree/master) - Production-focused version. | ||
@@ -592,2 +593,7 @@ | ||
#### rocky#retry([ opts, filter ]) | ||
Enable and define a custom retry logic as global configuration. | ||
See [`Route#retry`](#routeretry-opts-filter-) for details. | ||
#### rocky#on(event, handler) | ||
@@ -736,3 +742,3 @@ | ||
```js | ||
var customRetrytrategies = [ | ||
var customRetryStrategies = [ | ||
function invalidCodes(err, res) { | ||
@@ -744,2 +750,3 @@ return !err && [404, 406].indexOf(res.statusCode) !== -1 | ||
rocky() | ||
.get('/download/:id') | ||
.retry({ | ||
@@ -751,3 +758,3 @@ retries: 3, | ||
randomize: true, | ||
strategies: customRetrytrategies | ||
strategies: customRetryStrategies | ||
}) | ||
@@ -754,0 +761,0 @@ |
@@ -10,4 +10,3 @@ const sinon = require('sinon') | ||
req.headers = { foo: 'bar' } | ||
req.rocky = {} | ||
req.rocky.options = { foo: { bar: true }} | ||
req.rocky = { options: { foo: { bar: true }} } | ||
@@ -14,0 +13,0 @@ var newReq = common.cloneRequest(req) |
@@ -50,3 +50,3 @@ const fs = require('fs') | ||
test('proxy forward retry', function (done) { | ||
test('proxy forward with retry', function (done) { | ||
var spy = sinon.spy() | ||
@@ -80,3 +80,3 @@ | ||
test('proxy replay retry', function (done) { | ||
test('proxy replay with retry', function (done) { | ||
var spy = sinon.spy() | ||
@@ -184,2 +184,3 @@ server = createTestServer() | ||
.replay(replayUrl) | ||
.bufferBody() | ||
.listen(ports.proxy) | ||
@@ -198,3 +199,3 @@ | ||
.expect({ 'hello': 'world' }) | ||
.end() | ||
.end(function () {}) | ||
@@ -201,0 +202,0 @@ function assert(req, res) { |
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
124597
2829
958