-
-
Save samdark/87c56aaeb8b21208ebbfc91633792f8c to your computer and use it in GitHub Desktop.
routes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
// GET /api/post is executed as: | |
// | |
// FormatDataResponse -> FormatDataResponseAsJson -> AccessCheck -> FormatDataResponsAsXml | |
// -> action | |
// -> FormatDataResponsAsXml -> AccessCheck -> FormatDataResponseAsJson -> FormatDataResponse | |
return [ | |
// Variant 1 | |
Group::create(null) | |
->pipe(FormatDataResponse::class) | |
->routes([ | |
Group::create('/api') | |
->pipe(FormatDataResponseAsJson::class) | |
->pipe(AccessCheck::class) | |
->routes([ | |
Route::get('/post') | |
->pipe(FormatDataResponsAsXml::class) | |
->action([PostController::class, 'index']), | |
Route::post('/post') | |
->action([PostController::class, 'add']) | |
]), | |
]), | |
// Variant 2 (current version) | |
Group::create(null, [ | |
Group::create('/api', [ | |
Route::get('/post', [PostController::class, 'index']) | |
->addMiddleware(FormatDataResponsAsXml::class), | |
Route::post('/post', [PostController::class, 'add']), | |
])->addMiddleware(AccessCheck::class) | |
->addMiddleware(FormatDataResponseAsJson::class), | |
])->addMiddleware(FormatDataResponse::class) | |
]; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#[Route('/edit/{id}', name: 'users.edit')]