Customize HTML templates
Customize html templates in strong-error-handler, see https://github.com/strongloop/loopback/issues/1650#issuecomment-161920555 for details.
Configuration options:
// map of templates to use for rendering responses
views: {
// the default view
default: path.resolve(__dirname, 'views/error-default.jade'),
404: path.resolve(__dirname, 'views/error-not-found.jade'),
// etc.
},
// map of static files to send as a response
files: {
// default: path.resolve(__dirname, 'public/error.html'),
401: path.resolve(__dirname, 'views/error-unauthorized.html'),
// etc.
},
Requires #5
+1
what about something like
"final:after": {
"strong-error-handler": {
"params": {
"debug": true,
"log": false,
"htmlRenderer": "$!../path/to/html-renderer",
"jsonRenderer": "$!../path/to/json-renderer",
"xmlRenderer": "$!../path/to/xml-renderer",
"jsonSerializer": "$!../path/to/json-serializer"
}
}
}
See my attempt to roll this in: https://github.com/charlie-s/strong-error-handler/commit/c2335b34d213eaa2d8f3f658e957401ec4dcc036
Note that the order of arguments in negotiateContentProducer seemed to be incorrect (https://github.com/strongloop/strong-error-handler/issues/46) so that fix was included in this commit.
Using the above configuration and a function like
module.exports = function sendText(res, data) {
let content = `${data.name}: ${data.message} (${data.details}) [${data.code}]`;
res.setHeader('Content-Type', 'plain/text; charset=utf-8');
res.end(content, 'utf-8');
};
would this help address #6 as well?
is this ever going to be implemented?