Skip to content

Commit

Permalink
Merge pull request #26 from splinter/master
Browse files Browse the repository at this point in the history
Create API endpoints can now recieve asset details in content body
  • Loading branch information
splinter committed Apr 29, 2015
2 parents f4070f3 + 96ca2aa commit 038c1b6
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion apps/publisher/modules/asset-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var result;
var log = new Log('asset_api');
var exceptionModule = utils.exception;
var constants = rxtModule.constants;
var CONTENT_TYPE_JSON = 'application/json';
/**
*
* @param fieldParam The raw string comes as field parameter of the request
Expand Down Expand Up @@ -183,7 +184,22 @@ var result;
for (var key in meta) {
asset[key] = meta[key];
}
}
};
var processContentType = function(contentType){
var comps = contentType.split(';');
return comps [0];
};
var processRequestBody = function(req,assetReq){
var contentType = processContentType(req.getContentType());
if(contentType !== CONTENT_TYPE_JSON){
return assetReq;
}
var params = req.getContent();
for(var key in params){
assetReq[key] = params[key];
}
return assetReq;
};
/**
* api to create a new asset
* @param options incoming values
Expand All @@ -203,6 +219,7 @@ var result;
var rxtManager = getRxtManager(session,options.type);
var isLCEnabled = false;
var isDefaultLCEnabled = false;
assetReq = processRequestBody(req,assetReq);
if (request.getParameter("asset")) {
asset = parse(request.getParameter("asset"));
} else {
Expand Down

0 comments on commit 038c1b6

Please sign in to comment.