Sha256: 6f133b1ecdc5a73fc4651b5ddbe8c5829e00502c8d2b626eb20a32fb5dc589bb
Contents?: true
Size: 1.67 KB
Versions: 26
Compression:
Stored size: 1.67 KB
Contents
.\" generated with Ronn/v0.6.6 .\" http://github.com/rtomayko/ronn/ . .TH "ROUTER" "" "June 2010" "" "" . .SH "Rest" The \fIrouter\fR middleware provides a routing API similar to that of Sinatra and Express\. . .IP "" 4 . .nf function user(app) { app\.get(\'/users/(all\.:format?)?\', function(req, res){ // populates req\.format // ex: // GET /users // GET /users/all // GET /users/all\.json // GET /users/all\.xml }); app\.get(\'/users/:id\.:format?\': function(req, res){ // populates req\.format // populates params\.id // ex: // GET /user/5 // GET /user/5\.json // GET /user/5\.xml }); app\.put(\'/user/:id\', function(req, res, params){ // populates params\.id // ex: // PUT /user/2 }); app\.del(\'/user/:id/file/*\', function(req, res, params){ // populates params\.id // populates params\.splat[0] // ex: // PUT /user/4/file/javascripts/jquery\.js // PUT /user/4/file/stylecss }); } function commits(app) { // RegExps too! app\.get(/\\/commit\\/(\\w+)\\\.\\\.(\\w+)\\/?/i, function(req, res, params){ // populates params\.splat[0] with first capture group // populates params\.splat[1] with second capture group // ex: // GET /commit/kj4k\.\.d3sdf }); } connect\.createServer( connect\.router(user), connect\.router(commits), ); . .fi . .IP "" 0 . .P Those of you looking for \fIPUT\fR and \fIDELETE\fR support may want to take a look at the \fImethodOverride\fR middleware\. . .SS "See Also" . .IP "\(bu" 4 methodOverride . .IP "" 0
Version data entries
26 entries across 26 versions & 1 rubygems