1 | <?php |
||
13 | class AcceptParsedBodyToken |
||
14 | { |
||
15 | use RequestAttributesTrait; |
||
16 | |||
17 | /** |
||
18 | * Used to validate tokens. |
||
19 | * |
||
20 | * @var callable |
||
21 | */ |
||
22 | protected $tokenValidator; |
||
23 | |||
24 | /** |
||
25 | * Used to _get_ the token. |
||
26 | * |
||
27 | * @var string|int|mixed[] a `Schnittstabil\Get\getValue` path |
||
28 | */ |
||
29 | protected $path; |
||
30 | |||
31 | /** |
||
32 | * Create new AcceptParsedBodyToken middleware. |
||
33 | * |
||
34 | * @see https://github.com/schnittstabil/get Documentation of `Schnittstabil\Get\getValue` |
||
35 | * |
||
36 | * @param callable $tokenValidator Used to validate tokens |
||
37 | * @param string|int|mixed[] $path a `Schnittstabil\Get\getValue` path |
||
38 | */ |
||
39 | public function __construct(callable $tokenValidator, $path = 'X-XSRF-TOKEN') |
||
44 | |||
45 | /** |
||
46 | * Invoke middleware. |
||
47 | * |
||
48 | * @param ServerRequestInterface $request request object |
||
49 | * @param ResponseInterface $response response object |
||
50 | * @param callable $next next middleware |
||
51 | * |
||
52 | * @return ResponseInterface response object |
||
53 | */ |
||
54 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
73 | } |
||
74 |