Gitter migration: Setup redirects (rollout pt. 3)
[gitter.git] / server / handlers / uri-context / group-context-resolver-middleware.js
blobb3265e7e31d2c31a37addc4fdc2245f076c54fd4
1 'use strict';
3 var roomContextService = require('gitter-web-rooms/lib/room-context-service');
4 var debug = require('debug')('gitter:app:group-context-resolver-middleware');
6 function groupContextResolverMiddleware(req, res, next) {
7 var uri = req.params.groupUri;
8 debug('Looking up normalised uri %s', uri);
10 return roomContextService
11 .findContextForGroup(req.user, uri)
12 .then(function(uriContext) {
13 req.group = uriContext.group;
14 req.uriContext = uriContext;
16 .asCallback(next);
19 module.exports = groupContextResolverMiddleware;