add the middleware to detect the api version