Support promises in middleware