-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
rest.1
59 lines (57 loc) · 1.43 KB
/
rest.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
.\" generated with Ronn/v0.6.6
.\" http://github.com/rtomayko/ronn/
.
.TH "REST" "" "June 2010" "" ""
.
.SH "Rest"
The \fIrest\fR middleware provides a RESTful routing api similar to that of Sinatra and Express\.
.
.IP "" 4
.
.nf
var userRoutes = {
get: {
\'/users/(all\.:format?)?\': function(req, res) {
// populates req\.format
// ex:
// GET /users
// GET /users/all
// GET /users/all\.json
// GET /users/all\.xml
},
\'/user/:id\.:format?\': function(req, res, params) {
// populates req\.format
// populates params\.id
// ex:
// GET /user/5
// GET /user/5\.json
// GET /user/5\.xml
}
},
put: {
\'/user/:id\': function(req, res, params) {
// populates params\.id
// ex:
// PUT /user/2
}
},
del: {
\'/user/:id/file/*\': function(req, res, params) {
// populates params\.id
// populates params\.splat[0]
// ex:
// DELETE /user/4/file/javascripts/jquery\.js
// DELETE /user/4/file/style\.css
}
}
};
connect\.createServer([
{ provider: \'rest\', routes: userRoutes }
]);
.
.fi
.
.IP "" 0
.
.P
Those of you looking for \fIPUT\fR and \fIDELETE\fR support may want to take a look at the \fImethod\-override\fR middleware\.