Replies: 2 comments
-
the See #1246 for an example |
Beta Was this translation helpful? Give feedback.
0 replies
-
If I understand your need @amitshahc, I see two ways: Assign direct to route:// in your web.php
use App\Http\Middleware\EnsureTokenIsValid;
Route::get('/profile', function () {
// ...
})->middleware(EnsureTokenIsValid::class); Register and useRegister in bootstrap/app.php: return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
$middleware->alias([
'middleOne' => MiddlewareOne::class,
'middleTwo' => MiddlewareTwo::class,
]);
})
->withExceptions(function (Exceptions $exceptions) {
})->create(); use in web.php: Route::get('/', [AwesomeController::class, 'index'])
->middleware(['middleOne', 'middleTwo']); Laravel oficial documentation: https://laravel.com/docs/11.x/middleware#assigning-middleware-to-routes |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to create a new
middlewere
under the nwidart moduleTasks
and assign it to route level inside the module'sroute/web.php
onRoutes->group...->middlewere([xxx])
. but according to new laravel 11 middlewere registration inbootstrap/app.php
under->withMiddleware()
, i am totally confuse if it's global middlewere which i don't wont for all, only wants to map to module routes. but if i do not put the new middlewere there, it doesn't executes.What is the new way of registering route level middlewere under specific module?
Beta Was this translation helpful? Give feedback.
All reactions