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

Exclude method OPTIONS in the list of supported request methods #11

Closed

Conversation

harlekoy
Copy link
Contributor

No description provided.

Copy link
Owner

@julienbourdeau julienbourdeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OPTIONS should definitely be ignored 👌

I'm curious to understand when Route doesnt have a getName method before I merge.

return false;
}

if (isset($regex['uri']) && $regex['uri'] && preg_match($regex['uri'], $route->uri)) {
return false;
}

// Lets exclude OPTIONS in the list of methods supported
if (Str::is($event->request->getMethod(), 'OPTIONS')) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -33,15 +34,21 @@ protected function shouldLogUsage($event)

$route = $event->request->route();
$regex = config('route-usage.excluding-regex');
$name = method_exists($route, 'getName') ? $route->getName() : null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain when this method would not be defined?

@julienbourdeau
Copy link
Owner

Thanks for your contributions! 👍

@ingalless
Copy link
Contributor

Could you remove the dependency on \Illuminate\Support\Str by using the "isMethod()" method of the request?
Like so:

<?php $event->request->isMethod('options'); ?>

More info here

@julienbourdeau
Copy link
Owner

Good idea. It's also more readable.

Any reason why you want to remove the dependency to Str (since this package only works with Laravel anyway)?

@ingalless
Copy link
Contributor

ingalless commented Oct 28, 2019

@julienbourdeau None in particular, other than it could read a little better as you've said, and as it's on the request object Laravel will already be handling bizarre edge cases (if there are any?)

@julienbourdeau
Copy link
Owner

@ingalless @harlekoy In the end, I went for #12. Thanks for the suggestions and ideas 💯

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

Successfully merging this pull request may close these issues.

None yet

3 participants