Instance based middleware pattern