moved GETs into an object literal

This commit is contained in:
Montana Scott Rowe 2012-01-19 17:20:26 -06:00
parent c7d4a5cf33
commit c16d3a0f67

View file

@ -502,53 +502,61 @@ function init(additionalSetup){
var gets = {};
var gets = {
//serve static files
gets['/static/*'] = getStatic;
'/static/*': getStatic,
//serve minified files
gets['/minified/:id'] = getMinified;
'/minified/:id': getMinified,
//serve read only pad
gets['/ro/:id'] = getRoCombinator(
'/ro/:id': getRoCombinator(
serverName,
{ro: readOnlyManager},
hasPadAccess,
ERR,
exporthtml
);
),
//serve pad.html under /p
gets['/p/:pad'] = sendStaticIfPad(
'/p/:pad': sendStaticIfPad(
goToPad,
padManager,
path,
"pad.html"
);
)
//serve timeslider.html under /p/$padname/timeslider
gets['/p/:pad/timeslider'] = sendStaticIfPad(
'/p/:pad/timeslider': sendStaticIfPad(
goToPad, padManager, path, "timeslider.html"
);
),
//serve timeslider.html under /p/$padname/timeslider
//the above comment is wrong
gets['/p/:pad/:rev?/export/:type'] = getExportPadCombinator(
'/p/:pad/:rev?/export/:type': getExportPadCombinator(
goToPad, settings, hasPadAccess, exportHandler, serverName
);
),
//This is a api GET call, collect all post informations and pass it to the apiHandler
gets['/api/1/:func'] = function(req, res)
'/api/1/:func': function(req, res)
{
apiCaller(req, res, req.query)
}
},
//serve index.html under /
gets['/'] = function(req, res)
'/': function(req, res)
{
return sendStatic(path, res, "index.html");
}
},
//serve robots.txt
gets['/robots.txt'] = function(req, res)
'/robots.txt': function(req, res)
{
return sendStatic(path, res, "robots.txt");
}
},
//serve favicon.ico
gets['/favicon.ico'] = function(req, res)
'/favicon.ico': function(req, res)
{
return sendStatic(path, res, "custom/favicon.ico",
function(err){
@ -559,9 +567,10 @@ function init(additionalSetup){
res.sendfile(filePath, { maxAge: exports.maxAge });
}
});
}
};
for(var key in gets) app.get(key, gets[key]);
var posts = {};
//handle import requests
app.post('/p/:pad/import', postImportPadCombinator(goToPad, settings, serverName, hasPadAccess, importHandler));
@ -581,7 +590,10 @@ function init(additionalSetup){
app.post('/jserror', logOkPostCombinator("CLIENT SIDE JAVASCRIPT ERROR", "error", "errorInfo"));
additionalSetup();
additionalSetup(app, gets);
for(var key in gets) app.get(key, gets[key]);
//let the server listen
app.listen(settings.port, settings.ip);