Remove generic controller, its functionallity fits better in cors middleware
This commit is contained in:
parent
d85331e97b
commit
a383785e7c
@ -1,13 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = class GenericController {
|
||||
route (app) {
|
||||
app.options('*', emptyResponse());
|
||||
}
|
||||
};
|
||||
|
||||
function emptyResponse () {
|
||||
return function emptyResponseMiddleware (req, res) {
|
||||
res.end();
|
||||
};
|
||||
}
|
@ -21,6 +21,10 @@ module.exports = function cors(extraHeaders = []) {
|
||||
res.header('Access-Control-Allow-Headers', headers.join(', '));
|
||||
res.header('Access-Control-Expose-Headers', exposedHeaders.join(', '));
|
||||
|
||||
if (req.method === 'OPTIONS') {
|
||||
return res.send();
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
};
|
||||
|
@ -29,7 +29,6 @@ const Logger = require('./services/logger');
|
||||
var cors = require('./middlewares/cors');
|
||||
|
||||
const ApiRouter = require('./controllers/api-router');
|
||||
var GenericController = require('./controllers/generic_controller');
|
||||
var HealthCheckController = require('./controllers/health_check_controller');
|
||||
var VersionController = require('./controllers/version_controller');
|
||||
|
||||
@ -129,9 +128,6 @@ function App(statsClient) {
|
||||
const dataIngestionLogger = new Logger(global.settings.dataIngestionLogPath, 'data-ingestion');
|
||||
app.dataIngestionLogger = dataIngestionLogger;
|
||||
|
||||
var genericController = new GenericController();
|
||||
genericController.route(app);
|
||||
|
||||
var healthCheckController = new HealthCheckController();
|
||||
healthCheckController.route(app);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user