add extendResponse option to middleware