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

NeoIsRecursive / inertia-tempest / 14018560406

23 Mar 2025 11:34AM UTC coverage: 98.742% (+0.4%) from 98.305%
14018560406

push

github

NeoIsRecursive
chore: add mago for linting and formatting

44 of 44 new or added lines in 10 files covered. (100.0%)

2 existing lines in 1 file now uncovered.

157 of 159 relevant lines covered (98.74%)

12.38 hits per line

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

84.62
/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\Container\Container;
10
use Tempest\Core\KernelEvent;
11
use Tempest\EventBus\EventHandler;
12
use Tempest\Http\Method;
13
use Tempest\Http\Status;
14
use Tempest\Router\HttpMiddleware;
15
use Tempest\Router\HttpMiddlewareCallable;
16
use Tempest\Router\Request;
17
use Tempest\Router\Response;
18
use Tempest\Router\Router;
19

20
final class Middleware implements HttpMiddleware
21
{
22
    public function __construct(
23
        private Inertia $inertia,
24
        private Container $container,
25
    ) {
26
    }
40✔
27

28
    #[EventHandler(event: KernelEvent::BOOTED)]
29
    public function register(): void
30
    {
31
        $router = $this->container->get(Router::class);
40✔
32
        $router->addMiddleware(self::class);
40✔
33
    }
34

35
    public function __invoke(Request $request, HttpMiddlewareCallable $next): Response
36
    {
37
        /** @var Response $response */
38
        $response = $next($request);
1✔
39

40
        $response->addHeader('Vary', Header::INERTIA);
1✔
41

42
        if (!$request->headers->offsetExists(Header::INERTIA)) {
1✔
UNCOV
43
            return $response;
×
44
        }
45

46
        $versionHeaderValue = $request->headers[Header::VERSION] ?? '';
1✔
47

48
        if ($request->method === Method::GET && $versionHeaderValue !== $this->inertia->version) {
1✔
49
            // TODO: reflash session data
50

UNCOV
51
            return $this->inertia->location($request->uri);
×
52
        }
53

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

67
        return $response;
1✔
68
    }
69
}
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