Skip to content

Commit

Permalink
Allow configuration less mode with local session storage
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Aug 18, 2023
1 parent 7db222b commit 44d0431
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/SessionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
namespace Amp\Http\Server\Session;

use Amp\Sync\KeyedMutex;
use Amp\Sync\LocalKeyedMutex;

final class SessionFactory
{
public function __construct(
private readonly KeyedMutex $mutex,
private readonly SessionStorage $storage,
private readonly KeyedMutex $mutex = new LocalKeyedMutex(),
private readonly SessionStorage $storage = new LocalSessionStorage(),
private readonly SessionIdGenerator $idGenerator = new Base64UrlSessionIdGenerator(),
) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/SessionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class SessionMiddleware implements Middleware
* Defaults to {@see Session::class}.
*/
public function __construct(
private readonly SessionFactory $factory,
private readonly SessionFactory $factory = new SessionFactory(),
CookieAttributes $cookieAttributes = null,
private readonly string $cookieName = self::DEFAULT_COOKIE_NAME,
private readonly string $requestAttribute = Session::class
Expand Down

0 comments on commit 44d0431

Please sign in to comment.