While changing code in LodataServiceProvider I noticed that any error there also is thrown on any other route that does not have the Lodata prefix. This means that all the ODP discovery and setup is done for every request. In my case the ODP functionality is being added to an existing monolith so it adds a significant overhead to all requests to existing routes.
I worked around this by adding a check in the boot() method to see if the path of the request matches the configured Lodata prefix like this:
class LodataServiceProvider extends ServiceProvider
{
public function boot()
{
if (!self::isOdpRequest(\Request::path())) {
return;
}
// DO EVERYTHING ELSE
}
public static function isOdpRequest(string $path): bool
{
$prefix = \Config::get('lodata.prefix');
return str_starts_with($path, $prefix);
}
}
I think it is a good idea to add something like this to the Lodata library by default. Otherwise someone else with a similar issue might find this useful.
While changing code in LodataServiceProvider I noticed that any error there also is thrown on any other route that does not have the Lodata prefix. This means that all the ODP discovery and setup is done for every request. In my case the ODP functionality is being added to an existing monolith so it adds a significant overhead to all requests to existing routes.
I worked around this by adding a check in the boot() method to see if the path of the request matches the configured Lodata prefix like this:
I think it is a good idea to add something like this to the Lodata library by default. Otherwise someone else with a similar issue might find this useful.