How do you write custom middleware?