Skip to content

Commit

Permalink
Merge branch 'release/0.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Apr 20, 2012
2 parents 5011634 + e209e77 commit 6ce9080
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/webpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@ function Application(environment, schemaValidator){

exports.Application = Application;

/**
* @description Creates a new callback for the user-defined handler.
* @param {Object} operation The service operation.
* @param {Object} response HTTP response.
* @returns {Function} A new callback function.
*/
Application.prototype.createResponseCallback = function(operation, response){
//simple JSON serializer
if(operation.serialize == true) return function(value){ this.json(value); }.bind(response);
//custom serializer
else if(operation.serialize instanceof Function) return function(value){ this.serialize(value, response); }.bind({'response': response, 'serialize': operation.serialize});
else if(operation.serialize instanceof Function) return function(value){ this.serialize.call(this.response, value); }.bind({'response': response, 'serialize': operation.serialize});
//text serializer
else return function(value, statuscode){ this.send(value, statuscode); }.bind(response);
};
Expand Down Expand Up @@ -115,7 +121,7 @@ function execServiceOperation(request, response){
//prepares operation context
var context = new OperationContext(request, this.environment);
//Executes preparation function
(this.operation.prepare || asyncTrue).call(this.operation, context, function(){
(this.operation.prepare || asyncTrue).call(this.operation, context, response, function(){
//imports all validation arguments into the context
for(var i in arguments) context[i] = arguments[i];
execServiceOperationCore.call(this, context, request, response);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "webpoints",
"description": "ExpressJS-based RESTful service development framework",
"version": "0.0.4",
"version": "0.0.5",
"author": "Sakno Roman <sakno@tncor.com>",
"dependencies": {
"express": "2.5.8",
Expand Down

0 comments on commit 6ce9080

Please sign in to comment.