You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> You might also want to read: [Setting AWS Credentials in Node.js](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html)
For developers reference, default hooks implementation are located in `lib/default-hooks.js` file.
182
182
183
-
##The "*GET /services.json*" endpoint
183
+
# The "*GET /services.json*" endpoint
184
184
Since version `1.3.5` the gateway exposes minimal documentation about registered services at: `GET /services.json`
185
185
186
186
Example output:
@@ -201,7 +201,7 @@ Example output:
201
201
```
202
202
> NOTE: Please see `docs` configuration entry explained above.
203
203
204
-
##WebSockets support
204
+
# WebSockets
205
205
WebSockets proxying is supported since `v3.1.0`. Main considerations:
206
206
- The `faye-websocket` module dependency require to be installed:
207
207
```bash
@@ -229,7 +229,7 @@ WebSockets proxying is supported since `v3.1.0`. Main considerations:
229
229
```
230
230
- The `/` route prefix is considered the default route.
231
231
232
-
####Configuration example
232
+
## Configuration example
233
233
```js
234
234
gateway({
235
235
routes: [{
@@ -241,8 +241,8 @@ gateway({
241
241
}]
242
242
}).start(PORT)
243
243
```
244
-
##Traffic Management
245
-
###Timeouts and Unavailability
244
+
# Traffic Management
245
+
## Timeouts and Unavailability
246
246
We can restrict requests timeouts globally or at service level using the `timeout` configuration.
247
247
248
248
You can also define endpoints specific timeout using the property `timeout` of the request object, normally inside a middleware:
@@ -251,12 +251,12 @@ req.timeout = 500 // define a 500ms timeout on a custom request.
251
251
```
252
252
> NOTE: You might want to also check https://www.npmjs.com/package/middleware-if-unless
253
253
254
-
###Circuit Breakers
254
+
## Circuit Breakers
255
255
By using the `proxyHandler` hook, developers can optionally intercept and modify the default gateway routing behavior right before the origin request is proxied to the remote service. Therefore, connecting advanced monitoring mechanisms like [Circuit Breakers](https://martinfowler.com/bliki/CircuitBreaker.html) is rather simple.
256
256
257
257
Please see the `demos/circuitbreaker.js` example for more details using the `opossum` library.
258
258
259
-
###Rate Limiting
259
+
## Rate Limiting
260
260
[Rate limiting](https://en.wikipedia.org/wiki/Rate_limiting), as well many other gateway level features can be easily implemented using `fast-gateway`:
261
261
```js
262
262
constrateLimit=require('express-rate-limit')
@@ -288,7 +288,7 @@ gateway({
288
288
```
289
289
> In this example we have used the [express-rate-limit](https://www.npmjs.com/package/express-rate-limit) module.
290
290
291
-
##Hostnames support
291
+
# Hostnames support
292
292
We can also implement hostnames support with fast-gateway, basically we translate hostnames to prefixes:
293
293
```js
294
294
...
@@ -338,17 +338,17 @@ const hostnames2prefix = [{
338
338
```
339
339
For more details, please checkout the `basic-hostnames.js` demo.
340
340
341
-
## Gateway level caching
341
+
#Caching
342
342
Caching support is provided by the `http-cache-middleware` module. https://www.npmjs.com/package/http-cache-middleware
343
343
344
-
###Introduction
344
+
## Introduction
345
345
Enabling proper caching strategies at gateway level will drastically reduce the latency of your system,
346
346
as it reduces network round-trips and remote services processing.
347
347
We are talking here about improvements in response times from `X ms` to `~2ms`, as an example.
348
348
> We use the `http-cache-middleware` module to support gateway level caching. Read more about it: https://github.com/jkyberneees/http-cache-middleware
349
349
350
-
### Setting up gateway level cache available for all services
351
-
####Single node cache (memory)
350
+
##Caching responses from all services
351
+
### Single node cache (memory)
352
352
```js
353
353
// cache middleware
354
354
constcache=require('http-cache-middleware')()
@@ -361,7 +361,7 @@ const server = gateway({
361
361
```
362
362
> Memory storage is recommended if there is only one gateway instance and you are not afraid of losing cache data.
363
363
364
-
####Multi nodes cache (redis)
364
+
### Multi nodes cache (redis)
365
365
```js
366
366
// redis setup
367
367
constCacheManager=require('cache-manager')
@@ -388,13 +388,13 @@ const server = gateway({
388
388
```
389
389
> Required if there are more than one gateway instances
0 commit comments