Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated package.json and added support for PATCH

  • Loading branch information...
commit cf0458b7a85841eef6f8247591eff4dfdd28b735 1 parent 66f1882
@tarruda authored
View
2  package.json
@@ -1,7 +1,7 @@
{
"author": "Thiago de Arruda <tpadilha84@gmail.com>",
"name": "flask-router",
- "version": "0.0.3",
+ "version": "0.0.4",
"description": "Flask-inspired routing system for node and connect.\nNice if you just need a routing system without depending on connect, or need routing middleware without all features provided by express.",
"main": "./lib/router.js",
"repository": {
View
5 src/router.coffee
@@ -234,6 +234,7 @@ class Router
POST: []
PUT: []
DELETE: []
+ PATCH: []
@compiled = false
@@ -390,8 +391,10 @@ module.exports = (parsers) ->
r.register('put', 'PUT', pattern, handlers...)
del: (pattern, handlers...) ->
r.register('del', 'DELETE', pattern, handlers...)
+ patch: (pattern, handlers...) ->
+ r.register('patch', 'PATCH', pattern, handlers...)
all: (pattern, handlers...) ->
- for method in ['GET', 'POST', 'PUT', 'DELETE']
+ for method in ['GET', 'POST', 'PUT', 'DELETE', 'PATCH']
r.register('all', method, pattern, handlers...)
return handlers
}
View
17 test/router.coffee
@@ -27,6 +27,10 @@ describe 'Rules', ->
(req, res, next) -> res.write('p3'); next(),
(req, res, next) -> res.write('p4'); res.end()
+ router.patch '/patch-route', (req, res) ->
+ res.write('patched!')
+ res.end()
+
it 'should match simple patterns', (done) ->
app.request()
.get('/$imple/.get/pattern$')
@@ -46,16 +50,17 @@ describe 'Rules', ->
it 'should pipe request through all handlers', (done) ->
app.request()
.get('/^pattern/that/uses/many/handlers')
- .end (res) ->
- res.body.should.eql('part1part2part3')
- done()
+ .expect('part1part2part3', done)
it 'should cancel pipeline when handler ends the request', (done) ->
app.request()
.get('/cancel')
- .end (res) ->
- res.body.should.eql('p1p2')
- done()
+ .expect('p1p2', done)
+
+ it 'can also be registered to patch methods', (done) ->
+ app.request()
+ .patch('/patch-route')
+ .expect('patched!', done)
describe 'Pathname normalization', ->
View
2  test/support/http.js
@@ -2,7 +2,7 @@
* Module dependencies.
*/
var EventEmitter = require('events').EventEmitter
- , methods = ['get', 'post', 'put', 'delete', 'head']
+ , methods = ['get', 'post', 'put', 'delete', 'head', 'patch']
, connect = require('connect')
, http = require('http');
Please sign in to comment.
Something went wrong with that request. Please try again.