Simplify approach to checking for html response in middleware