Skip to content
Myr

docs for app.match.VERB()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 41266aa · Browse files · 1 file+32 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+32 added−3 removed

  • other:+32 added−3 removed

1 file+32 added−3 removed

modified:docs/guide.md+32 added-3 removed
1171 unmodified lines
11721173 The _app.lookup_ http methods returns an array of callback functions1174 associated with the given _path_.11751176 Suppose you define the following routes:1176 Suppose we define the following routes:1177 1178 app.get('/user/:id', function(){});1179 app.get('/user/:id/op?', function(){});1179 app.put('/user/:id', function(){});1180 app.get('/user/:id/:op?', function(){});11811182 We can utilize this lookup functionality to check which routes1183 have been defined, which can be extremely useful for higher level1184 frameworks built on Express.11851186 app.lookup.get('/user/:id');1187 // => [Function]11881189 app.lookup.get('/user/:id/op?');1189 app.lookup.get('/user/:id/:op?');1190 // => [Function]11911192 app.lookup.put('/user/:id');1193 // => [Function]
10 unmodified lines
1204 1205 app.lookup.get('/user');1206 app.get('/user');12071208### app.match12091210 The _app.match_ http methods return an array of callback functions1211 which match the given _url_, which may include a query string etc. This1212 is useful when you want reflect on which routes have the opportunity to1213 respond.12141215 Suppose we define the following routes:12161217 app.get('/user/:id', function(){});1218 app.put('/user/:id', function(){});1219 app.get('/user/:id/:op?', function(){});12201221 Our match against __GET__ will return two functions, since the _:op_1222 in our second route is optional.12231224 app.match.get('/user/1');1225 // => [Function, Function]12261227 This second call returns only the callback for _/user/:id/:op?_.12281229 app.match.get('/user/23/edit');1230 // => [Function]12311232 We can also use _all()_ to disregard the http method:12331234 app.match.all('/user/20');1235 // => [Function, Function, Function]12361237### app.mounted(fn)12381239Assign a callback _fn_ which is called when this _Server_ is passed to _Server#use()_.1240
65 unmodified lines