[HY-757] Make middleware configurable