improved detection of API requests in Controller