8000 Discovery occurs for all requests, even ones without the Lodata prefix · Issue #815 · flat3/lodata · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Discovery occurs for all requests, even ones without the Lodata prefix #815
Open
@John5

Description

@John5

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0