Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for route:cache #49

Open
craftisan opened this issue Sep 22, 2020 · 0 comments
Open

Fix for route:cache #49

craftisan opened this issue Sep 22, 2020 · 0 comments

Comments

@craftisan
Copy link

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();
            });
        }
    }
craftisan added a commit to craftisan/laravel-api-tester that referenced this issue Sep 22, 2020
- Renamed namespaces
- Updated package versions compatible only for laravel 7.0 & above
- changed config('api-tester.enabled') value to env('API_TESTER')
- Fixed asvae#50 (comment)
- Fixed asvae#49 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant