add doc section how to write middleware