added middleware support
added middleware support