Created
September 14, 2017 01:42
-
-
Save devotox/5c9e0a5684ce321f7d44abb2027b4024 to your computer and use it in GitHub Desktop.
Ember Fastboot onVisit Middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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