Skip to content

Commit c2e9fd4

Browse files
authored
Merge pull request #75 from thoov/metadata
Add metadata option for .visit
2 parents 904f30d + ca45c59 commit c2e9fd4

3 files changed

Lines changed: 15 additions & 4 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) {

test/fastboot-info-test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe("FastBootInfo", function() {
99
var response;
1010
var request;
1111
var fastbootInfo;
12+
var metadata = { foo: 'bar' };
1213

1314
beforeEach(function () {
1415
response = {};
@@ -22,7 +23,7 @@ describe("FastBootInfo", function() {
2223
}
2324
};
2425

25-
fastbootInfo = new FastBootInfo(request, response);
26+
fastbootInfo = new FastBootInfo(request, response, { metadata });
2627
});
2728

2829
it("has a FastBootRequest", function() {
@@ -32,5 +33,8 @@ describe("FastBootInfo", function() {
3233
it("has a FastBootResponse", function() {
3334
expect(fastbootInfo.response).to.be.an.instanceOf(FastBootResponse);
3435
});
35-
});
3636

37+
it("has metadata", function() {
38+
expect(fastbootInfo.metadata).to.deep.equal(metadata);
39+
});
40+
});

0 commit comments

Comments
 (0)