@zambezi/address
Advanced tools
Comparing version 3.0.5 to 3.1.0
@@ -113,2 +113,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
, into | ||
, timeout = 30 | ||
, dispatcher = dispatch.apply(null, codes.range().concat(['err', 'done'])) | ||
@@ -125,2 +126,3 @@ | ||
body = r.body || body | ||
timeout = r.timeout || timeout | ||
} | ||
@@ -275,2 +277,8 @@ | ||
api.timeout = function(v) { | ||
if(!arguments.length) return timeout | ||
timeout = v | ||
return api | ||
} | ||
return rebind(api, dispatcher, 'on') | ||
@@ -288,2 +296,3 @@ | ||
, origin: origin | ||
, timeout: timeout | ||
} | ||
@@ -1214,9 +1223,15 @@ | ||
requestTimeout : function(req, res, next) { | ||
var responded | ||
, timeout = setTimeout(function() { | ||
responded = true | ||
res(null, error(408)) | ||
}, 30000) | ||
, timeout | ||
if(req.timeout > 0) { | ||
timeout = setTimeout(function() { | ||
responded = true | ||
res(null, error(408)) | ||
}, req.timeout * 1000) | ||
} else { | ||
responded = true | ||
throw new Error('Invalid timeout: must be an integer value greater than 0') | ||
} | ||
next(req, function(err, data) { | ||
@@ -1223,0 +1238,0 @@ clearTimeout(timeout) |
{ | ||
"name": "@zambezi/address", | ||
"version": "3.0.5", | ||
"version": "3.1.0", | ||
"description": "API for nap resources", | ||
@@ -5,0 +5,0 @@ "main": "lib/address.js", |
@@ -307,2 +307,15 @@ # Address | ||
### Adding timeout | ||
When requesting a resource address will by default wait at least 30 seconds for a response from the resource, before returning a `408 Request Timeout` error. By calling the `timeout` method on the request, it is possible to increase or decrease this timeout period. The following example shows how to increase the timeout from the default 30 seconds to 60: | ||
```javascript | ||
// increase the timeout to 60 sec for request to resolve | ||
address("/price/usd/gbp") | ||
.timeout(60) | ||
.json() | ||
.get() | ||
``` | ||
The value given to the `timeout` method is in seconds. | ||
## Adding a resource view to the DOM | ||
@@ -309,0 +322,0 @@ |
Sorry, the diff of this file is not supported yet
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
110619
1178
539