Skip to content

Instantly share code, notes, and snippets.

@devotox
Created September 14, 2017 01:42
Show Gist options
  • Save devotox/5c9e0a5684ce321f7d44abb2027b4024 to your computer and use it in GitHub Desktop.
Save devotox/5c9e0a5684ce321f7d44abb2027b4024 to your computer and use it in GitHub Desktop.
Ember Fastboot onVisit Middleware
// ember-cli-fastboot/index.js
let fastbootMiddleware = FastBootExpressMiddleware({
+ onVisit: fastbootConfig.onVisit,
fastboot: this.fastboot
});
// fastboot-express-middleware/src/index.js
function fastbootExpressMiddleware(distPath, options) {
return function(req, res, next) {
let path = req.url;
- fastboot.visit(path, { request: req, response: res })
+ let html = opts.onVisit && opts.onVisit(path)
+ fastboot.visit(path, { request: req, response: res, html })
.then(success, failure);
// fastboot-server/src/worker.js
// passed down from src/fastboot-server.js
return fastbootMiddleware({
- fastboot: this.fastboot
+ fastboot: this.fastboot,
+ onVisit: this.onVisit
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment