Skip to content

Commit b69e6ed

Browse files
authored
docs(index): sync createServer and Server constructor docs (#1678)
1 parent 06f3fc8 commit b69e6ed

File tree

4 files changed

+33
-26
lines changed

4 files changed

+33
-26
lines changed

docs/_api/server.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,17 @@ routes and handlers for incoming requests.
6464
- `options.handleUpgrades` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Hook the `upgrade` event
6565
from the node HTTP server, pushing `Connection: Upgrade` requests through the
6666
regular request handling chain. (optional, default `false`)
67+
- `options.onceNext` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Prevents calling next multiple
68+
times (optional, default `false`)
69+
- `options.strictNext` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Throws error when next() is
70+
called more than once, enabled onceNext option (optional, default `false`)
6771
- `options.httpsServerOptions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Any options accepted by
6872
[node-https Server](http://nodejs.org/api/https.html#https_https).
6973
If provided the following restify server options will be ignored:
7074
spdy, ca, certificate, key, passphrase, rejectUnauthorized, requestCert and
7175
ciphers; however these can all be specified on httpsServerOptions.
72-
- `options.onceNext` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Prevents calling next multiple
73-
times (optional, default `false`)
74-
- `options.strictNext` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Throws error when next() is
75-
called more than once, enabled onceNext option (optional, default `false`)
76+
- `options.noWriteContinue` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** prevents
77+
`res.writeContinue()` in `server.on('checkContinue')` when proxing (optional, default `false`)
7678
- `options.ignoreTrailingSlash` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** ignore trailing slash
7779
on paths (optional, default `false`)
7880

docs/guides/server.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,14 @@ function sendV1(req, res, next) {
307307
}
308308

309309
function sendV2(req, res, next) {
310-
res.send({hello: req.params.name});
310+
res.send({ hello: req.params.name });
311311
return next();
312312
}
313313

314-
var PATH = '/hello/:name';
315-
server.get({path: PATH, version: '1.1.3'}, sendV1);
316-
server.get({path: PATH, version: '2.0.0'}, sendV2);
314+
server.get('/hello/:name', restify.plugins.conditionalHandler([
315+
{ version: '1.1.3', handler: sendV1 },
316+
{ version: '2.0.0', handler: sendV2 }
317+
]));
317318

318319
server.listen(8080);
319320
```
@@ -347,25 +348,28 @@ creation time. Lastly, you can support multiple versions in the API by using
347348
an array:
348349

349350
```js
350-
server.get({path: PATH, version: ['2.0.0', '2.1.0', '2.2.0']}, sendV2);
351+
server.get('/hello/:name' restify.plugins.conditionalHandler([
352+
{ version: ['2.0.0', '2.1.0', '2.2.0'], handler: sendV2 }
353+
]));
351354
```
352355

353356
In this case you may need to know more information such as what the original
354357
requested version string was, and what the matching version from the routes
355358
supported version array was. Two methods make this info available:
356359

357360
```js
358-
var PATH = '/version/test';
359-
server.get({
360-
path: PATH,
361-
version: ['2.0.0', '2.1.0', '2.2.0']
362-
}, function (req, res, next) {
363-
res.send(200, {
364-
requestedVersion: req.version(),
365-
matchedVersion: req.matchedVersion()
366-
});
367-
return next();
368-
});
361+
server.get('/version/test', restify.plugins.conditionalHandler([
362+
{
363+
version: ['2.0.0', '2.1.0', '2.2.0'],
364+
handler: function (req, res, next) {
365+
res.send(200, {
366+
requestedVersion: req.version(),
367+
matchedVersion: req.matchedVersion()
368+
});
369+
return next();
370+
}
371+
}
372+
]));
369373
```
370374

371375
Hitting this route will respond as below:

docs/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ function sendV1(req, res, next) {
317317
}
318318

319319
function sendV2(req, res, next) {
320-
res.send({hello: req.params.name});
320+
res.send({ hello: req.params.name });
321321
return next();
322322
}
323323

@@ -368,7 +368,6 @@ requested version string was, and what the matching version from the routes
368368
supported version array was. Two methods make this info available:
369369

370370
```js
371-
var PATH = '/version/test';
372371
server.get('/version/test', restify.plugins.conditionalHandler([
373372
{
374373
version: ['2.0.0', '2.1.0', '2.2.0'],

lib/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,17 @@ require('./errorTypes');
4646
* @param {Boolean} [options.handleUpgrades=false] - Hook the `upgrade` event
4747
* from the node HTTP server, pushing `Connection: Upgrade` requests through the
4848
* regular request handling chain.
49+
* @param {Boolean} [options.onceNext=false] - Prevents calling next multiple
50+
* times
51+
* @param {Boolean} [options.strictNext=false] - Throws error when next() is
52+
* called more than once, enabled onceNext option
4953
* @param {Object} [options.httpsServerOptions] - Any options accepted by
5054
* [node-https Server](http://nodejs.org/api/https.html#https_https).
5155
* If provided the following restify server options will be ignored:
5256
* spdy, ca, certificate, key, passphrase, rejectUnauthorized, requestCert and
5357
* ciphers; however these can all be specified on httpsServerOptions.
54-
* @param {Boolean} [options.onceNext=false] - Prevents calling next multiple
55-
* times
56-
* @param {Boolean} [options.strictNext=false] - Throws error when next() is
57-
* called more than once, enabled onceNext option
58+
* @param {Boolean} [options.noWriteContinue=false] - prevents
59+
* `res.writeContinue()` in `server.on('checkContinue')` when proxing
5860
* @param {Boolean} [options.ignoreTrailingSlash=false] - ignore trailing slash
5961
* on paths
6062
* @example

0 commit comments

Comments
 (0)