Skip to content

Fix for route:cache #49

Open
Open
@craftisan

Description

@craftisan

The hack that is applied to stop route caching is not just hacky, it very hacky and way too inelegant. There is much simpler solution which I believe should have an been obvious choice.
Instead of blocking the caching of routes by doing this:

$router->any('* routes should not be cached',[
    'as' => 'routes-should not be cached',
    'uses' =>  function () { return 'Api-tester routes-should not be cached';},
]);

Just simply register the route conditionally in RouteServiceProvider according to APP_DEBUG value, like so:

    public function map(Router $router)
    {
        if(config('api-tester.enabled')) {
            $router->group([
                'as' => 'api-tester.',
                'prefix' => config('api-tester.route'),
                'namespace' => $this->getNamespace(),
                'middleware' => $this->getMiddleware(),
            ], function () {
                $this->requireRoutes();
            });
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions