Skip to content

Commit fa8b6b5

Browse files
committed
feat: do not thread cache server when registering routes
1 parent 217a3bf commit fa8b6b5

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
All notable changes to this project will be documented in this file. This project adheres to
44
[Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/).
55

6+
## Unreleased
7+
8+
### Changed
9+
10+
- Registering routes no longer results in the server instance being thread-cached. This more accurately reflects
11+
production environments, where routes would be cached so there would be no thread-cached JSON:API server when handling
12+
a HTTP request. This means tests (and development environments where routes are not cached) more accurately behave in
13+
the same way as production environments.
14+
615
## [3.1.0] - 2023-07-20
716

817
### Added

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"require": {
2626
"php": "^8.1",
2727
"ext-json": "*",
28-
"laravel-json-api/core": "^3.2",
29-
"laravel-json-api/eloquent": "^3.0",
28+
"laravel-json-api/core": "^3.3",
29+
"laravel-json-api/eloquent": "^3.1",
3030
"laravel-json-api/encoder-neomerx": "^3.0",
3131
"laravel-json-api/exceptions": "^2.0",
3232
"laravel-json-api/spec": "^2.0",
@@ -65,7 +65,7 @@
6565
]
6666
}
6767
},
68-
"minimum-stability": "stable",
68+
"minimum-stability": "dev",
6969
"prefer-stable": true,
7070
"config": {
7171
"sort-packages": true

src/Routing/Registrar.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
use Illuminate\Contracts\Routing\Registrar as RegistrarContract;
2323
use LaravelJsonApi\Contracts\Server\Repository;
24+
use LaravelJsonApi\Core\Server\ServerRepository;
2425

2526
class Registrar
2627
{
@@ -55,9 +56,15 @@ public function __construct(RegistrarContract $router, Repository $servers)
5556
*/
5657
public function server(string $name): PendingServerRegistration
5758
{
59+
// TODO add the `once` method to the server repository interface
60+
$server = match(true) {
61+
$this->servers instanceof ServerRepository => $this->servers->once($name),
62+
default => $this->servers->server($name),
63+
};
64+
5865
return new PendingServerRegistration(
5966
$this->router,
60-
$this->servers->server($name)
67+
$server,
6168
);
6269
}
6370
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy