Skip to content

Commit

Permalink
Prim Server Middleware (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
pushpak1300 authored Nov 20, 2024
1 parent d38aba1 commit 962a0be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/prism.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

return [
'prism_server' => [
// The middleware that will be applied to the Prism Server routes.
'middleware' => [],
'enabled' => env('PRISM_SERVER_ENABLED', true),
],
'providers' => [
Expand Down
10 changes: 10 additions & 0 deletions docs/core-concepts/prism-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,13 @@ With this setup, you can access your Prism models through a user-friendly chat i

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.

## Adding Middleware

You can add middleware to the Prism Server routes by setting the `middleware` option in your `config/prism.php` file:

```php
'prism_server' => [
'middleware' => ['web'],
// ...
],
```
7 changes: 6 additions & 1 deletion src/PrismServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace EchoLabs\Prism;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;

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

if (config('prism.prism_server.enabled')) {
$this->loadRoutesFrom(__DIR__.'/Routes/PrismServer.php');
Route::group([
'middleware' => config('prism.prism_server.middleware', []),
], function (): void {
$this->loadRoutesFrom(__DIR__.'/Routes/PrismServer.php');
});
}
}

Expand Down

0 comments on commit 962a0be

Please sign in to comment.