This options block feels pretty huge, and it's somewhat distracting from what you want to focus on in this code, namely, the middleware we're using, and its order.  Can you do this somewhere else, and pass it in?  Or move more of this to config?