Adding middleware required for bug 838251.
Merge pull request #1267 from brandonsavage/bug838251-middleware

Adding middleware required for bug 838251.