mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
moved GETs into an object literal
This commit is contained in:
parent
c7d4a5cf33
commit
c16d3a0f67
1 changed files with 60 additions and 48 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue