Skip to content
Myr

Added FauxMethod module

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

authored by visionmedia · committed by visionmedia · parent 7807f42 · Browse files · 1 file+29 added−8 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+29 added−8 removed

  • other:+29 added−8 removed

1 file+29 added−8 removed

modified:lib/express.core.js+29 added-8 removed
50 unmodified lines
51 },52 53 DefaultContentType : {54 onRequest : {55 'set content type to text/html' : function() {55 'set response content type to text/html' : function() {56 Express.header('Content-Type', 'text/html')57 }58 }59 },60 61 FormBodyDecoder : {61 BodyDecoder : {62 onRequest : {63 'parse urlencoded bodies' : function() {64 if (Express.requestHeader('Content-Type') == 'application/x-www-form-urlencoded')65 Express.request.uri.params = Express.parseParams(unescape(Express.request.body))66 }67 }68 },69 70 FauxMethod : {71 onRequest : {72 'set HTTP method to _method when present' : function() {73 if (method = Express.param('_method'))74 Express.request.method = method.toUpperCase()75 }76 }77 },78 79 Logger : {80 onRequest : {81 'output log data' : function(){82 puts('"' + Express.request.method + ' ' + Express.request.uri.path +
16 unmodified lines
99 var results = []100 for (i = 0, len = this.modules.length; i < len; ++i)101 for (var key in this.modules[i][name])102 if (this.modules[i][name].hasOwnProperty(key))94 results.push(this.modules[i][name][key].apply(this.modules[i], this.argsArray(arguments, 1)))103 results.push(this.modules[i][name][key].apply(this.modules[i], this.argsArray(arguments, 1))) 104 return results105 },106 107 /**
89 unmodified lines
197 Express.response.body = null198 Express.response.status = 200199 Express.request = request200 request.headers = Express.arrayToHash(request.headers)192 Express.hook('onEarlyRequest')201 request.uri.params = Express.parseNestedParams(request.uri.params)202 request.uri.path = Express.normalizePath(request.uri.path)203 Express.hook('onRequest')204 try { Express.response.body = Express.callRouteFor(request) }
451 unmodified lines
656 657 }658 }659 652 // --- Utilities653 660 // --- Expose661 662 get = Express.routeFunctionFor('get')663 post = Express.routeFunctionFor('post')
2 unmodified lines
666 use = Express.addModule667 668 // --- Core Modules669 664 use(Express.RedirectHelpers)670 use(Express.BodyDecoder)671 use(Express.FauxMethod)672 use(Express.ContentLength)673 use(Express.DefaultContentType)667 use(Express.FormBodyDecoder)674 use(Express.RedirectHelpers)675 676})()677678get('user', function(){679 '<form action="/user" method="post"><input type="hidden" name="_method" value="put" /><input type="submit" /></form>'680})681682put('user', function(){683 p('PUT')684})685686del('user', function(){687 p('DELETE')688})689690Express.start()