-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
34 lines (27 loc) · 844 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
use Zored\SpeechBundle\Endpoint\Context\ServiceContext;
use Zored\SpeechBundle\Endpoint\EndpointBuilder;
use Zored\SpeechBundle\Subscriber\UUID4Subscriber;
use Zored\SpeechBundle\Test\Functional\JsonRpc\Greeter;
// Composer class autoloader:
require __DIR__ . '/../autoload.php';
// Get JSON from GET or POST:
switch($_SERVER['REQUEST_METHOD']) {
default:
case 'GET':
$json = $_GET['request'];
break;
case 'POST':
$json = file_get_contents('php://input');
break;
}
// JSON response:
header('Content-Type: application/json');
// Available services:
$context = new ServiceContext(['your.service']);
// Echo output:
echo (new EndpointBuilder())
// ->addSubscriber(new UUID4Subscriber())
->addService('your.service', Greeter::class)
->getEndpoint()
->handle($json, $context);