Skip to content
Myr

respond() -> halt()

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

authored by visionmedia · committed by visionmedia · parent 8a32670 · Browse files · 2 files+6 added−6 removed
This commit

State

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

Diff stats

2 files+6 added−6 removed

  • tests:+3 added−3 removed
  • other:+3 added−3 removed

2 files+6 added−6 removed

modified:lib/express.core.js+3 added-3 removed
68 unmodified lines
69 settings : {70 basepath : '/',71 defaultRoute : {72 callback : function() {73 Express.respond('Page or file cannot be found', 'Not Found')73 Express.halt('Page or file cannot be found', 'Not Found')74 }75 }76 },77
240 unmodified lines
318 */319 320 redirect : function(uri) {321 this.header('Location', uri)322 this.respond("Page or file has moved to `" + uri + "'", 'Moved Temporarily')322 this.halt("Page or file has moved to `" + uri + "'", 'Moved Temporarily')323 },324 325 /**326 * Set response status to _value_. Where value may be
32 unmodified lines
359 * @param {string, int} status360 * @api public361 */362 363 respond : function(body, status) {363 halt : function(body, status) {364 this.response.body = body365 this.status(status)366 throw new Express.Halt()367 },
328 unmodified lines
modified:spec/spec.core.js+3 added-3 removed
114 unmodified lines
115 Express.response.status.should.eql 403116 end117 end118 119 describe '.respond()'119 describe '.halt()'120 after_each121 Express.response.status = 200122 end123 124 it 'should set response status and body'125 -{ Express.respond('Page or file cannot be found', 'Not Found') }.should.throw_error125 -{ Express.halt('Page or file cannot be found', 'Not Found') }.should.throw_error126 Express.response.status.should.eql 404127 Express.response.body.should.eql 'Page or file cannot be found'128 end129 130 it 'should allow specific status to be passed'131 -{ Express.respond('File cannot be found', 404) }.should.throw_error131 -{ Express.halt('File cannot be found', 404) }.should.throw_error132 Express.response.status.should.eql 404133 Express.response.body.should.eql 'File cannot be found'134 end135 end
91 unmodified lines