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
106
node/server.js
106
node/server.js
|
@ -502,66 +502,75 @@ function init(additionalSetup){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var gets = {};
|
var gets = {
|
||||||
//serve static files
|
//serve static files
|
||||||
gets['/static/*'] = getStatic;
|
'/static/*': getStatic,
|
||||||
|
|
||||||
//serve minified files
|
//serve minified files
|
||||||
gets['/minified/:id'] = getMinified;
|
'/minified/:id': getMinified,
|
||||||
|
|
||||||
//serve read only pad
|
//serve read only pad
|
||||||
gets['/ro/:id'] = getRoCombinator(
|
'/ro/:id': getRoCombinator(
|
||||||
serverName,
|
serverName,
|
||||||
{ro: readOnlyManager},
|
{ro: readOnlyManager},
|
||||||
hasPadAccess,
|
hasPadAccess,
|
||||||
ERR,
|
ERR,
|
||||||
exporthtml
|
exporthtml
|
||||||
);
|
),
|
||||||
|
|
||||||
//serve pad.html under /p
|
//serve pad.html under /p
|
||||||
gets['/p/:pad'] = sendStaticIfPad(
|
'/p/:pad': sendStaticIfPad(
|
||||||
goToPad,
|
goToPad,
|
||||||
padManager,
|
padManager,
|
||||||
path,
|
path,
|
||||||
"pad.html"
|
"pad.html"
|
||||||
);
|
)
|
||||||
|
|
||||||
//serve timeslider.html under /p/$padname/timeslider
|
//serve timeslider.html under /p/$padname/timeslider
|
||||||
gets['/p/:pad/timeslider'] = sendStaticIfPad(
|
'/p/:pad/timeslider': sendStaticIfPad(
|
||||||
goToPad, padManager, path, "timeslider.html"
|
goToPad, padManager, path, "timeslider.html"
|
||||||
);
|
),
|
||||||
|
|
||||||
//serve timeslider.html under /p/$padname/timeslider
|
//serve timeslider.html under /p/$padname/timeslider
|
||||||
//the above comment is wrong
|
//the above comment is wrong
|
||||||
gets['/p/:pad/:rev?/export/:type'] = getExportPadCombinator(
|
'/p/:pad/:rev?/export/:type': getExportPadCombinator(
|
||||||
goToPad, settings, hasPadAccess, exportHandler, serverName
|
goToPad, settings, hasPadAccess, exportHandler, serverName
|
||||||
);
|
),
|
||||||
|
|
||||||
//This is a api GET call, collect all post informations and pass it to the apiHandler
|
//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)
|
apiCaller(req, res, req.query)
|
||||||
}
|
},
|
||||||
|
|
||||||
//serve index.html under /
|
//serve index.html under /
|
||||||
gets['/'] = function(req, res)
|
'/': function(req, res)
|
||||||
{
|
{
|
||||||
return sendStatic(path, res, "index.html");
|
return sendStatic(path, res, "index.html");
|
||||||
}
|
},
|
||||||
|
|
||||||
//serve robots.txt
|
//serve robots.txt
|
||||||
gets['/robots.txt'] = function(req, res)
|
'/robots.txt': function(req, res)
|
||||||
{
|
{
|
||||||
return sendStatic(path, res, "robots.txt");
|
return sendStatic(path, res, "robots.txt");
|
||||||
}
|
},
|
||||||
|
|
||||||
//serve favicon.ico
|
//serve favicon.ico
|
||||||
gets['/favicon.ico'] = function(req, res)
|
'/favicon.ico': function(req, res)
|
||||||
{
|
{
|
||||||
return sendStatic(path, res, "custom/favicon.ico",
|
return sendStatic(path, res, "custom/favicon.ico",
|
||||||
function(err){
|
function(err){
|
||||||
//there is no custom favicon, send the default favicon
|
//there is no custom favicon, send the default favicon
|
||||||
if(err)
|
if(err)
|
||||||
{
|
{
|
||||||
filePath = path.normalize(__dirname + "/../static/favicon.ico");
|
filePath = path.normalize(__dirname + "/../static/favicon.ico");
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for(var key in gets) app.get(key, gets[key]);
|
var posts = {};
|
||||||
|
|
||||||
//handle import requests
|
//handle import requests
|
||||||
app.post('/p/:pad/import', postImportPadCombinator(goToPad, settings, serverName, hasPadAccess, importHandler));
|
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"));
|
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
|
//let the server listen
|
||||||
app.listen(settings.port, settings.ip);
|
app.listen(settings.port, settings.ip);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue