Skip to content

Commit

Permalink
published configs won't have "web" middleware added (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
mszulik authored Sep 4, 2024
1 parent 44e39c7 commit 62bda6f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
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 middlewares are now fully configurable
- the `SubstituteBindings` middleware is now always applied as it is necessary to resolve route model bindings
- when `transmorpher.routeMiddleware` is not set, the `web` and `auth` middlewares are applied
- 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.

8 changes: 4 additions & 4 deletions amigor/config/transmorpher.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
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 middlewares applied to routes provided by this package:
// - the "SubstituteBindings" middleware will be applied additionally.
// - "web" and "auth" middlewares will be applied when this is not set.
'routeMiddleware' => [],

'api' => [
// Optionally, specify the Transmorpher API version which should be used. For supported versions, check the SupportedApiVersion enum.
Expand Down
8 changes: 4 additions & 4 deletions config/transmorpher.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
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 middlewares applied to routes provided by this package:
// - the "SubstituteBindings" middleware will be applied additionally.
// - "web" and "auth" middlewares will be applied when this is not set.
// '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

0 comments on commit 62bda6f

Please sign in to comment.