A more complete middleware example