Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize HTML templates #3

Open
loay opened this issue May 5, 2016 · 5 comments
Open

Customize HTML templates #3

loay opened this issue May 5, 2016 · 5 comments

Comments

@loay
Copy link
Contributor

loay commented May 5, 2016

Customize html templates in strong-error-handler, see strongloop/loopback#1650 (comment) 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

@bajtos bajtos added this to the #Epic: Production Error Handler milestone May 5, 2016
@bajtos bajtos added the feature label May 5, 2016
@bajtos bajtos mentioned this issue May 11, 2016
@bajtos bajtos added the #tob label May 12, 2016
@bajtos bajtos added #plan and removed #tob labels Jun 9, 2016
@bajtos bajtos added #tob and removed #plan labels Jun 24, 2016
@bajtos bajtos removed this from the #Epic: Production Error Handler milestone Jul 19, 2016
@bajtos bajtos added #tob and removed #plan labels Aug 4, 2016
@davidcheung davidcheung removed the #tob label Nov 18, 2016
@michaelfreund
Copy link

+1

@michaelfreund
Copy link

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"
    }
  }
}

@charlie-s
Copy link
Contributor

charlie-s commented Feb 28, 2017

See my attempt to roll this in: charlie-s@c2335b3

Note that the order of arguments in negotiateContentProducer seemed to be incorrect (#46) so that fix was included in this commit.

@charlie-s
Copy link
Contributor

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?

@selfagency
Copy link

is this ever going to be implemented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants