• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NeoIsRecursive / inertia-tempest / 16088818889

05 Jul 2025 01:58PM UTC coverage: 98.286% (-0.6%) from 98.851%
16088818889

push

github

NeoIsRecursive
feat: reflash session values

0 of 1 new or added line in 1 file covered. (0.0%)

172 of 175 relevant lines covered (98.29%)

10.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/src/Http/Middleware.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace NeoIsRecursive\Inertia\Http;
6

7
use NeoIsRecursive\Inertia\Inertia;
8
use NeoIsRecursive\Inertia\Support\Header;
9
use Tempest\Core\Priority;
10
use Tempest\Http\Method;
11
use Tempest\Http\Request;
12
use Tempest\Http\Response;
13
use Tempest\Http\Session\Session;
14
use Tempest\Http\Status;
15
use Tempest\Router\HttpMiddleware;
16
use Tempest\Router\HttpMiddlewareCallable;
17

18
#[Priority(Priority::HIGH)]
19
final class Middleware implements HttpMiddleware
20
{
21
    public function __construct(
22
        private Inertia $inertia,
23
        private Session $session,
24
    ) {}
1✔
25

26
    public function __invoke(Request $request, HttpMiddlewareCallable $next): Response
27
    {
28
        /** @var Response $response */
29
        $response = $next($request);
1✔
30

31
        $response->addHeader(
1✔
32
            key: 'Vary',
1✔
33
            value: Header::INERTIA,
1✔
34
        );
1✔
35

36
        if (!$request->headers->has(Header::INERTIA)) {
1✔
37
            return $response;
×
38
        }
39

40
        $versionHeaderValue = $request->headers->get(Header::VERSION) ?? '';
1✔
41

42
        if ($request->method === Method::GET && $versionHeaderValue !== $this->inertia->version) {
1✔
NEW
43
            $this->session->reflash();
×
44

45
            return $this->inertia->location($request->uri);
×
46
        }
47

48
        if (
49
            $response->status === Status::FOUND &&
1✔
50
                in_array($request->method, [Method::POST, Method::PUT, Method::PATCH], strict: true)
1✔
51
        ) {
52
            // TODO: set status to 303
53
            // return new GenericResponse(
54
            //     status: Status::SEE_OTHER,
55
            //     headers: [
56
            //         'Location' => $response->getHeader('Location'),
57
            //     ]
58
            // );
59
        }
60

61
        return $response;
1✔
62
    }
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc