Skip to content

Commit 057dcab

Browse files
author
Eran Hammer
committed
Fix table(). Closes hapijs#2276
1 parent 47daf49 commit 057dcab

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

API.md

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,11 +1517,13 @@ Returns a copy of the routing table where:
15171517
- `host` - optional host to filter routes matching a specific virtual host. Defaults to all virtual
15181518
hosts.
15191519

1520-
The return value is an object where each key is the `connection.info.uri` value of each connection
1521-
and the value is an array of routes where each route contains:
1522-
- `settings` - the route config with defaults applied.
1523-
- `method` - the HTTP method in lower case.
1524-
- `path` - the route path.
1520+
The return value is an array where each item is an object containing:
1521+
- `info` - the `connection.info` the connection the table was generated for.
1522+
- `labels` - the connection labels.
1523+
- `table` - an array of routes where each route contains:
1524+
- `settings` - the route config with defaults applied.
1525+
- `method` - the HTTP method in lower case.
1526+
- `path` - the route path.
15251527

15261528
Note that if the server has not been started and multiple connections use port `0`, the table items
15271529
will override each other and will produce an incomplete result.
@@ -1533,22 +1535,10 @@ server.connection({ port: 80, host: 'example.com' });
15331535
server.route({ method: 'GET', path: '/example', handler: function (request, reply) { return reply(); } });
15341536

15351537
var table = server.table();
1536-
1537-
/*
1538-
{
1539-
'http://example.com:80': [
1540-
{
1541-
method: 'get',
1542-
path: '/example',
1543-
settings: { ... }
1544-
}
1545-
]
1546-
}
1547-
*/
15481538
```
15491539

15501540
When calling `connection.table()` directly on each connection, the return value is the same as the
1551-
array value assigned to each connection record:
1541+
array `table` item value of an individual connection:
15521542

15531543
```js
15541544
var Hapi = require('hapi');

0 commit comments

Comments
 (0)