Skip to content

Commit 22c95b4

Browse files
committed
Add metaData option for .visit
Allows an option of metaData to be passed into options like: fastboot.visit('', { metaData: { foo: 'bar' } }); This enables per request information to be passed into the app such as user session info.
1 parent 58f0542 commit 22c95b4

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/ember-app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ class EmberApp {
199199
let html = options.html || this.html;
200200

201201
let bootOptions = buildBootOptions();
202-
let fastbootInfo = new FastBootInfo(req, res, this.hostWhitelist);
202+
let fastbootInfo = new FastBootInfo(
203+
req,
204+
res,
205+
{ hostWhitelist: this.hostWhitelist, metaData: options.metaData }
206+
);
203207
let doc = bootOptions.document;
204208

205209
let instance;

src/fastboot-info.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ var FastBootResponse = require('./fastboot-response');
77
* current HTTP request from FastBoot. This is injected
88
* on to the FastBoot service.
99
*/
10-
function FastBootInfo(request, response, hostWhitelist) {
10+
function FastBootInfo(request, response, options = {}) {
11+
const { hostWhitelist, metaData } = options;
12+
1113
this.deferredPromise = RSVP.resolve();
1214
if (request) {
1315
this.request = new FastBootRequest(request, hostWhitelist);
1416
}
1517

1618
this.response = new FastBootResponse(response || {});
19+
this.metaData = metaData;
1720
}
1821

1922
FastBootInfo.prototype.deferRendering = function(promise) {

0 commit comments

Comments
 (0)