Skip to content

Instantly share code, notes, and snippets.

@dvv
Created June 16, 2010 19:05
Show Gist options
  • Save dvv/441122 to your computer and use it in GitHub Desktop.
Save dvv/441122 to your computer and use it in GitHub Desktop.
publicFacets.root = {
hello: function(request, nextApp){
return {
status: 200,
headers: {'Content-Type': 'text/plain'},
body: ['Hello, world!\n']
};
},
bar: function(){
return 'BAR';
}
};
require('pintura/jsgi/faceted').FacetAuthorization = function(facetSelector, nextApp){
return function(request){
request.allowedFacets = request.security.getAllowedFacets(request.remoteUser, request)
.concat([AuthenticateFacet]);
var parts;
dir(request.pathInfo);
if ((parts = request.pathInfo.split('/')) && parts.length == 2) {
var method = parts[1];
var facet;
dir(request.allowedFacets.root);
if (request.allowedFacets && (facet = request.allowedFacets.root) && facet && facet.hasOwnProperty(method)) {
var result = facet[method](request, nextApp);
return result;
}
}
request.store = facetSelector(request);
return nextApp(request);
//Set the content type header with the schema
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment