mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
moved GET functions into an object
This commit is contained in:
parent
1b03e1991a
commit
c7d4a5cf33
1 changed files with 50 additions and 42 deletions
|
@ -504,33 +504,67 @@ function init(additionalSetup){
|
||||||
|
|
||||||
var gets = {};
|
var gets = {};
|
||||||
//serve static files
|
//serve static files
|
||||||
app.get('/static/*', getStatic);
|
gets['/static/*'] = getStatic;
|
||||||
|
|
||||||
//serve minified files
|
//serve minified files
|
||||||
app.get('/minified/:id', getMinified);
|
gets['/minified/:id'] = getMinified;
|
||||||
|
|
||||||
//serve read only pad
|
//serve read only pad
|
||||||
app.get('/ro/:id', getRoCombinator(serverName, {ro: readOnlyManager}, hasPadAccess, ERR, exporthtml));
|
gets['/ro/:id'] = getRoCombinator(
|
||||||
|
serverName,
|
||||||
|
{ro: readOnlyManager},
|
||||||
|
hasPadAccess,
|
||||||
|
ERR,
|
||||||
|
exporthtml
|
||||||
|
);
|
||||||
//serve pad.html under /p
|
//serve pad.html under /p
|
||||||
app.get('/p/:pad', sendStaticIfPad(goToPad, padManager, path, "pad.html"));
|
gets['/p/:pad'] = sendStaticIfPad(
|
||||||
|
goToPad,
|
||||||
|
padManager,
|
||||||
|
path,
|
||||||
|
"pad.html"
|
||||||
|
);
|
||||||
//serve timeslider.html under /p/$padname/timeslider
|
//serve timeslider.html under /p/$padname/timeslider
|
||||||
app.get('/p/:pad/timeslider', sendStaticIfPad(goToPad, padManager, path, "timeslider.html"));
|
gets['/p/:pad/timeslider'] = sendStaticIfPad(
|
||||||
|
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
|
||||||
app.get('/p/:pad/:rev?/export/:type', getExportPadCombinator(goToPad, settings, hasPadAccess, exportHandler, serverName));
|
gets['/p/:pad/:rev?/export/:type'] = getExportPadCombinator(
|
||||||
|
goToPad, settings, hasPadAccess, exportHandler, serverName
|
||||||
//handle import requests
|
);
|
||||||
app.post('/p/:pad/import', postImportPadCombinator(goToPad, settings, serverName, hasPadAccess, importHandler));
|
|
||||||
|
|
||||||
//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
|
||||||
app.get('/api/1/:func', function(req, res)
|
gets['/api/1/:func'] = function(req, res)
|
||||||
{
|
{
|
||||||
apiCaller(req, res, req.query)
|
apiCaller(req, res, req.query)
|
||||||
});
|
}
|
||||||
|
//serve index.html under /
|
||||||
|
gets['/'] = function(req, res)
|
||||||
|
{
|
||||||
|
return sendStatic(path, res, "index.html");
|
||||||
|
}
|
||||||
|
//serve robots.txt
|
||||||
|
gets['/robots.txt'] = function(req, res)
|
||||||
|
{
|
||||||
|
return sendStatic(path, res, "robots.txt");
|
||||||
|
}
|
||||||
|
//serve favicon.ico
|
||||||
|
gets['/favicon.ico'] = function(req, res)
|
||||||
|
{
|
||||||
|
return sendStatic(path, res, "custom/favicon.ico",
|
||||||
|
function(err){
|
||||||
|
//there is no custom favicon, send the default favicon
|
||||||
|
if(err)
|
||||||
|
{
|
||||||
|
filePath = path.normalize(__dirname + "/../static/favicon.ico");
|
||||||
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
for(var key in gets) app.get(key, gets[key]);
|
||||||
|
|
||||||
|
//handle import requests
|
||||||
|
app.post('/p/:pad/import', postImportPadCombinator(goToPad, settings, serverName, hasPadAccess, importHandler));
|
||||||
//This is a api POST call, collect all post informations and pass it to the apiHandler
|
//This is a api POST call, collect all post informations and pass it to the apiHandler
|
||||||
app.post('/api/1/:func', function(req, res)
|
app.post('/api/1/:func', function(req, res)
|
||||||
{
|
{
|
||||||
|
@ -546,32 +580,6 @@ function init(additionalSetup){
|
||||||
//The Etherpad client side sends information about client side javscript errors
|
//The Etherpad client side sends information about client side javscript errors
|
||||||
app.post('/jserror', logOkPostCombinator("CLIENT SIDE JAVASCRIPT ERROR", "error", "errorInfo"));
|
app.post('/jserror', logOkPostCombinator("CLIENT SIDE JAVASCRIPT ERROR", "error", "errorInfo"));
|
||||||
|
|
||||||
//serve index.html under /
|
|
||||||
app.get('/', function(req, res)
|
|
||||||
{
|
|
||||||
return sendStatic(path, res, "index.html");
|
|
||||||
});
|
|
||||||
|
|
||||||
//serve robots.txt
|
|
||||||
app.get('/robots.txt', function(req, res)
|
|
||||||
{
|
|
||||||
return sendStatic(path, res, "robots.txt");
|
|
||||||
});
|
|
||||||
|
|
||||||
//serve favicon.ico
|
|
||||||
app.get('/favicon.ico', function(req, res)
|
|
||||||
{
|
|
||||||
return sendStatic(path, res, "custom/favicon.ico",
|
|
||||||
function(err){
|
|
||||||
//there is no custom favicon, send the default favicon
|
|
||||||
if(err)
|
|
||||||
{
|
|
||||||
filePath = path.normalize(__dirname + "/../static/favicon.ico");
|
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
additionalSetup();
|
additionalSetup();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue