Created
June 16, 2010 19:05
-
-
Save dvv/441122 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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