Adds middleware