Skip to content

Commit 810c381

Browse files
committed
tweaks
1 parent e069a07 commit 810c381

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

index.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
var _ = require('lodash');
22

3-
exports.register = function(server, initial, next) {
4-
var self = this;
3+
exports.register = function(server, options, next) {
54

6-
this.addContext = function(request, key, data) {
5+
options = options || {};
6+
7+
var addContext = function(request, key, data) {
78
var response = request.response;
89

9-
if (response.variety !== 'view') return;
10+
if (response.variety !== 'view') {
11+
return;
12+
}
1013

1114
response.source.context = _.set(response.source.context || {}, key, data);
1215

1316
return response.source.context;
1417
};
1518

16-
server.expose('addContext', this.addContext);
19+
server.expose('addContext', addContext);
1720

1821
server.ext('onPreResponse', function(request, reply) {
19-
_.forIn(initial, function(value, key) {
20-
self.addContext(request, key, value);
22+
_.forIn(options.context, function(value, key) {
23+
addContext(request, key, value);
2124
});
2225

2326
reply.continue();

0 commit comments

Comments
 (0)