Skip to content

Commit

Permalink
Allow overriding render options
Browse files Browse the repository at this point in the history
See vercel#722 as well, but I can imagine more use cases.
  • Loading branch information
ehtb authored Jan 10, 2017
1 parent 4fcc551 commit 8cf7aff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,19 @@ export default class Server {
sendHTML(res, html)
}

async renderToHTML (req, res, pathname, query) {
async renderToHTML (req, res, pathname, query, opts = {}) {
if (this.dev) {
const compilationErr = this.getCompilationError(pathname)
if (compilationErr) {
res.statusCode = 500
return this.renderErrorToHTML(compilationErr, req, res, pathname, query)
}
}

const _opts = Object.assign(this.renderOpts, opts)

try {
return await renderToHTML(req, res, pathname, query, this.renderOpts)
return await renderToHTML(req, res, pathname, query, _opts)
} catch (err) {
if (err.code === 'ENOENT') {
res.statusCode = 404
Expand Down

0 comments on commit 8cf7aff

Please sign in to comment.