Created
September 29, 2010 16:24
-
-
Save dmachi/603050 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
| exports.urlMap = function(map, nextApp){ | |
| return function(request){ | |
| for (var i = 0; i<map.length; i++){ | |
| var match = map[i][0]; | |
| var ctor = map[i][1]; | |
| var returnRequest = map[i][2]; | |
| if (request.pathInfo.match(match)){ | |
| print("found match:", match); | |
| var res = ctor(request, match); | |
| if (res && returnRequest) return res; | |
| return nextApp(request); | |
| } | |
| } | |
| return nextApp(request); | |
| } | |
| } | |
| exports.rewrite = function(replacement){ | |
| return function(request, match ){ | |
| request.pathInfo=request.pathInfo.replace(match, replacement); | |
| } | |
| } | |
| exports.redirect = function(replacement){ | |
| var redirector = require("jack/redirect").Redirect(replacement); | |
| return function(request){ | |
| return redirector(request); | |
| } | |
| } |
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
| var urlConf = [ | |
| [/^\/$/, rewrite("/blog/test")], | |
| [/redir$/, redirect("/blog/test"), true] | |
| ]; | |
| var nodes = multiNode.listen({port: settings.port || 8080, nodes: settings.processes || 1}, | |
| require( "http" ).createServer( | |
| require("jsgi-node").Listener( | |
| // uncomment this to enable compression with node-compress | |
| //require("pintura/jsgi/compress").Compress( | |
| require("commonjs-utils/urlmap").urlMap(urlConf, | |
| require("pintura/jsgi/cascade").Cascade([ | |
| // cascade from static to pintura REST handling | |
| // the main place for static files accessible from the web | |
| Static({urls:[""], root: "public", directoryListing: true}), | |
| Static({urls:["/explorer"], root: require("nodules").getCachePath("persevere-client/") + "/explorer"}), | |
| // this will provide access to the server side JS libraries from the client | |
| require("transporter/jsgi/transporter").Transporter({ | |
| loader: require("nodules").forEngine("browser").useLocal().getModuleSource}), | |
| // main pintura app | |
| function(request){ | |
| return pinturaApp(request); | |
| } | |
| ]) | |
| ) | |
| //) | |
| ) | |
| ) | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment