summaryrefslogtreecommitdiff
path: root/tests/http/payload.php
blob: a16984c56b5378efa2eb4dc1583e2f248a47c81a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface
{
    // we expect json body
    $p = json_decode($req->getBody(), true);
    $resp->getBody()->write(json_encode(array_flip($p)));

    return $resp;
}