[bug 883149] Added custom middleware support