8000 Feature: allow middleware registration per action on resource and relations by lindyhopchris · Pull Request #268 · laravel-json-api/laravel · GitHub
[go: up one dir, main page]

Skip to content
8000

Feature: allow middleware registration per action on resource and relations #268

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

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

lindyhopchris
Copy link
Contributor

See #265

This PR adds the ability to register middleware per action, on both resource and relationship routes.

Usage for resource:

$server->resource('posts')->middleware([
    '*' => 'foo', // applied to all actions
    'show' => 'bar', // applied to just the show action
    'store' => ['baz1', 'baz2'], // use an array for multiple middleware
]);

Relationship is the same, using our short-hands for the actions:

$relationships->hasMany('tags')->middleware([
    '*' => 'foo', // applied to all
    'related' => 'bar',
    'attach' => ['baz1', 'baz2'],
]);

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.

1 participant
0