Skip to content
Myr

Throwing exception when body is not a string

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

Will soon allow objects with toString() ...

authored by visionmedia · committed by visionmedia · parent e516dcb · Browse files · 1 file+11 added−4 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+11 added−4 removed

  • other:+11 added−4 removed

1 file+11 added−4 removed

modified:lib/express.core.js+11 added-4 removed
526 unmodified lines
527 var route = this.findRouteFor(request) || this.settings.defaultRoute528 if (route.keys)529 for (i = 0, len = route.keys.length; i < len; ++i) 530 this.request.uri.params[route.keys[i]] = Express.captures[i+1] || null531 return this.eval(Express.contentsOf(route.callback)).toString()531 var body = this.eval(Express.contentsOf(route.callback))532 if (typeof body != 'string') 533 throw "route `" + route.method.toUpperCase() + ' ' + route.originalPath + "' must return a string"534 return body535 },536 537 /**538 * Attemp to find and return a route matching _request_.
36 unmodified lines
575 576 routeFunctionFor : function(method) {577 return function(path, options, callback) {578 if (options.constructor == Function) callback = options, options = {}576 path = Express.pathToRegexp(Express.normalizePath(path))579 Express.routes.push({580 keys : Express.regexpKeys,579 path : path,581 path : Express.pathToRegexp(Express.normalizePath(path)),582 originalPath : path,583 method : method,584 options : options,585 callback : callback586 })
39 unmodified lines
626use(Express.Logger)627628get('login', function(){629 ' \627 <form action="/" method="post"> \630 <form action="/login" method="post"> \631 <label>Username:</label> \632 <input type="text" name="user[name]"> \633 <label>Password:</label> \634 <input type="password" name="user[password]"> \
2 unmodified lines
637 </form> \638 ' 639})640641post('login', function(){642 'test'643})644645Express.start()