Skip to content

Commit 962a0be

Browse files
authored
Prim Server Middleware (#66)
1 parent d38aba1 commit 962a0be

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Diff for: config/prism.php

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
return [
44
'prism_server' => [
5+
// The middleware that will be applied to the Prism Server routes.
6+
'middleware' => [],
57
'enabled' => env('PRISM_SERVER_ENABLED', true),
68
],
79
'providers' => [

Diff for: docs/core-concepts/prism-server.md

+10
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,13 @@ With this setup, you can access your Prism models through a user-friendly chat i
9999

100100
By leveraging Prism Server, you can create powerful, custom AI experiences while maintaining compatibility with a wide ecosystem of tools and libraries. Whether you're building a chatbot, a content generation tool, or something entirely new, Prism Server provides the flexibility and standardization you need to succeed.
101101

102+
## Adding Middleware
103+
104+
You can add middleware to the Prism Server routes by setting the `middleware` option in your `config/prism.php` file:
105+
106+
```php
107+
'prism_server' => [
108+
'middleware' => ['web'],
109+
// ...
110+
],
111+
```

Diff for: src/PrismServiceProvider.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace EchoLabs\Prism;
44

5+
use Illuminate\Support\Facades\Route;
56
use Illuminate\Support\ServiceProvider;
67

78
class PrismServiceProvider extends ServiceProvider
@@ -13,7 +14,11 @@ public function boot(): void
1314
], 'prism-config');
1415

1516
if (config('prism.prism_server.enabled')) {
16-
$this->loadRoutesFrom(__DIR__.'/Routes/PrismServer.php');
17+
Route::group([
18+
'middleware' => config('prism.prism_server.middleware', []),
19+
], function (): void {
20+
$this->loadRoutesFrom(__DIR__.'/Routes/PrismServer.php');
21+
});
1722
}
1823
}
1924

0 commit comments

Comments
 (0)