Add the function 'register_middlewares'.

`register_middlewares` can register many middlewares.