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

published configs won't have "web" middleware added #36

Merged
merged 11 commits into from
Sep 4, 2024
1 change: 1 addition & 0 deletions .github/workflows/pullpreview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: transmorpher-env
include-hidden-files: true
path: |
placeholderSoFilePathsArePreserved
amigor/.env.transmorpher
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Release Notes

## [v0.4.0](https://github.com/cybex-gmbh/laravel-transmorpher-client/compare/v0.3.0...v0.4.0)

> [!WARNING]
> Breaking change!

- Route middleware is now fully configurable
- the `SubstituteBindings` middleware is now always applied as it is necessary to resolve route model bindings
- the `web` and `auth` middlewares are now only applied by default when no config value is set
- already published config files have to be adjusted accordingly
4 changes: 2 additions & 2 deletions amigor/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions amigor/config/transmorpher.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
return [
'client_name' => env('TRANSMORPHER_CLIENT_NAME'),

// The middleware applied to routes provided by this package. The 'web' middleware is necessary and applied by default.
'routeMiddleware' => [
// 'auth'
],
// The middleware applied to routes provided by this package.
// The SubstituteBindings middleware is always applied.
'routeMiddleware' => ['web'],

'api' => [
// Optionally, specify the Transmorpher API version which should be used. For supported versions, check the SupportedApiVersion enum.
Expand Down
7 changes: 3 additions & 4 deletions config/transmorpher.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
return [
'client_name' => env('TRANSMORPHER_CLIENT_NAME'),

// The middleware applied to routes provided by this package. The 'web' middleware is necessary and applied by default.
'routeMiddleware' => [
'auth'
],
// The middleware applied to routes provided by this package.
// The SubstituteBindings middleware is always applied.
// 'routeMiddleware' => ['web', 'auth'],

'api' => [
// Optionally, specify the Transmorpher API version which should be used. For supported versions, check the SupportedApiVersion enum.
Expand Down
3 changes: 2 additions & 1 deletion src/TransmorpherServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Transmorpher;

use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function register(): void
protected function registerRoutes(): void
{
Route::post(config('transmorpher.api.notifications_route'), ApiController::class)->name('transmorpherNotifications');
Route::middleware(array_merge(['web'], config('transmorpher.routeMiddleware', [])))->group(function () {
Route::middleware(array_merge(config('transmorpher.routeMiddleware', ['web', 'auth']), [SubstituteBindings::class]))->group(function () {
Route::post('transmorpher/{transmorpherMedia}/token', [UploadController::class, 'getUploadToken'])->name('transmorpherUploadToken');
Route::post('transmorpher/handleUploadResponse/{transmorpherUpload}', [UploadController::class, 'handleUploadResponse'])->name('transmorpherHandleUploadResponse');
Route::post('transmorpher/{transmorpherMedia}/state', [UploadStateController::class, 'getState'])->name('transmorpherState');
Expand Down