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
- `metrics.statusCode` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** status code of the response. can be
- `metrics.totalLatency` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** latency includes both request is flushed
1149
+
and all handlers finished
1150
+
- `metrics.latency` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** latency when request is flushed
1151
+
- `metrics.preLatency` **([Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | null)** pre handlers latency
1152
+
- `metrics.useLatency` **([Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | null)** use handlers latency
- `metrics.path` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** `req.path()` value
1084
1155
- `metrics.inflightRequests` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number of inflight requests pending
1085
1156
in restify.
1086
1157
- `metrics.unifinishedRequests` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Same as `inflightRequests`
1087
-
- `metrics.connectionState` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** can be either `'close'`,
1088
-
`'aborted'`, or `undefined`. If this value is set, err will be a
1089
-
corresponding `RequestCloseError` or `RequestAbortedError`.
1158
+
- `metrics.connectionState` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** can be either `'close'` or
1159
+
`undefined`. If this value is set, err will be a
1160
+
corresponding `RequestCloseError`.
1090
1161
If connectionState is either
1091
-
`'close'` or `'aborted'`, then the `statusCode` is not applicable since the
1162
+
`'close'`, then the `statusCode` is not applicable since the
1092
1163
connection was severed before a response was written.
1093
1164
- `req` **[Request](https://developer.mozilla.org/Add-ons/SDK/High-Level_APIs/request)** the request obj
1094
1165
- `res` **[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)** the response obj
Copy file name to clipboardexpand all lines: docs/_api/server.md
+16-38
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,6 @@ permalink: /docs/server-api/
21
21
-[pre](#pre)
22
22
-[use](#use)
23
23
-[param](#param)
24
-
-[versionedUse](#versioneduse)
25
24
-[rm](#rm)
26
25
-[address](#address)
27
26
-[inflightRequests](#inflightrequests)
@@ -39,12 +38,11 @@ routes and handlers for incoming requests.
39
38
40
39
**Parameters**
41
40
42
-
-`options`**[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** an options object
41
+
-`options`**[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** an options object
43
42
-`options.name`**[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the server. (optional, default `"restify"`)
43
+
-`options.dtrace`**[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** enable DTrace support (optional, default `false`)
-`options.version`**([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\|[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))?** Default version(s) to use in all
47
-
routes.
48
46
-`options.acceptable`**[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** String)|List of content-types this
49
47
server can respond with.
50
48
-`options.url`**[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Once listen() is called, this will be filled
@@ -59,7 +57,8 @@ routes and handlers for incoming requests.
59
57
will use a domain to catch and respond to any uncaught
-`options.version`**([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\|[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))?** Default version(s) to use in all
103
-
routes.
104
102
-`options.acceptable`**[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?** List of content-types this
105
103
server can respond with.
106
104
-`options.url`**[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Once listen() is called, this will be filled
@@ -114,6 +112,7 @@ Creates a new Server.
114
112
-`options.handleUncaughtExceptions`**[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** When true restify
115
113
will use a domain to catch and respond to any uncaught
116
114
exceptions that occur in it's handler stack.
115
+
Comes with significant negative performance impact.
Piggy-backs on the `server.use` method. It attaches a new middleware
346
-
function that only fires if the specified version matches the request.
347
-
348
-
Note that if the client does not request a specific version, the middleware
349
-
function always fires. If you don't want this set a default version with a
350
-
pre handler on requests where the client omits one.
351
-
352
-
Exposes an API:
353
-
server.versionedUse("version", function (req, res, next, ver) {
354
-
// do stuff that only applies to routes of this API version
355
-
});
356
-
357
-
**Parameters**
358
-
359
-
-`versions`**([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\|[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))** the version(s) the URL to respond to
360
-
-`fn`**[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** the middleware function to execute, the
361
-
fourth parameter will be the selected
362
-
version
363
-
364
-
Returns **[undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)** no return value
365
-
366
346
### rm
367
347
368
348
Removes a route from the server.
369
349
You pass in the route 'blob' you got from a mount call.
370
350
371
351
**Parameters**
372
352
373
-
-`route`**[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the route name.
353
+
-`routeName`**[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the route name.
374
354
375
355
376
356
- Throws **[TypeError](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypeError)** on bad input.
-`name`**[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a name for the route
773
-
-`path`**([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\|[Regexp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp))**a string or regex matching the route
774
-
-`version`**([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\|[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)** versions supported by this route
752
+
-`path`**[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**can be any String accepted by
0 commit comments