Middlewares are optionally arrays

Hey,

I made it so middlewares can either passed in the way they used to be or as an array.

Could you merge this PR in to your repo?  It will then update the PR you have on the main repo and I'll merge it in.

Thanks