Use functions as generic middleware.