Extract middleware