Revert "[server] make renderApp async"

This reverts commit 2671cdbefe.
This commit is contained in:
spalger 2016-03-16 16:45:19 -07:00
parent c79182754a
commit 1dcfed6597
2 changed files with 13 additions and 17 deletions

View file

@ -20,9 +20,9 @@ module.exports = function (kbnServer, server, config) {
}
});
server.decorate('reply', 'renderStatusPage', async function () {
server.decorate('reply', 'renderStatusPage', function () {
var app = kbnServer.uiExports.getHiddenApp('status_page');
var resp = app ? await this.renderApp(app) : this(kbnServer.status.toString());
var resp = app ? this.renderApp(app) : this(kbnServer.status.toString());
resp.code(kbnServer.status.isGreen() ? 200 : 503);
return resp;
});
@ -30,8 +30,8 @@ module.exports = function (kbnServer, server, config) {
server.route({
method: 'GET',
path: '/status',
handler: async function (request, reply) {
return await reply.renderStatusPage();
handler: function (request, reply) {
return reply.renderStatusPage();
}
});
};

View file

@ -46,29 +46,25 @@ module.exports = async (kbnServer, server, config) => {
server.route({
path: '/app/{id}',
method: 'GET',
handler: async function (req, reply) {
handler: function (req, reply) {
let id = req.params.id;
let app = uiExports.apps.byId[id];
if (!app) return reply(Boom.notFound('Unknown app ' + id));
if (kbnServer.status.isGreen()) {
return await reply.renderApp(app);
return reply.renderApp(app);
} else {
return await reply.renderStatusPage();
return reply.renderStatusPage();
}
}
});
async function getDefaultInjectedVars() {
const vars = Promise.map(uiExports.defaultVariableInjectors, async injector => {
const toInject = await injector();
return toInject || {};
});
const getDefaultInjectedVars = once(function createDefaultInjectedVars() {
const injectors = uiExports.defaultVariableInjectors;
return defaults({}, ...injectors.map(injector => (injector() || {})));
});
return defaults({}, ...vars);
};
server.decorate('reply', 'renderApp', async function (app) {
server.decorate('reply', 'renderApp', function (app) {
const payload = {
app: app,
nav: uiExports.apps,
@ -76,7 +72,7 @@ module.exports = async (kbnServer, server, config) => {
buildNum: config.get('pkg.buildNum'),
buildSha: config.get('pkg.buildSha'),
basePath: config.get('server.basePath'),
vars: defaults(app.getInjectedVars() || {}, await getDefaultInjectedVars()),
vars: defaults(app.getInjectedVars() || {}, getDefaultInjectedVars()),
};
return this.view(app.templateName, {