diff --git a/examples/server.php b/examples/custromString.php similarity index 85% rename from examples/server.php rename to examples/custromString.php index 375f8e3..a513daa 100644 --- a/examples/server.php +++ b/examples/custromString.php @@ -12,8 +12,6 @@ include __DIR__ . '/../vendor/autoload.php'; $requestBuilder = new JsonRpcRequestBuilder(new JsonSerializer()); -$input = new InputStream($requestBuilder); - $input = new CustomStringInput( '[{"jsonrpc":"2.0", "method": "sampleMethod", "params":[], "id":1}, {"jsonrpc":"2.0", "method": "sampleMethod", "params":[]}]', $requestBuilder @@ -27,10 +25,10 @@ $handler->registerForMethod('sampleMethod', $sampleHandler); $server = new JsonRpcServer( - $handler, - new JsonRpcRequestBuilder(new JsonSerializer()) + $handler ); $response = $server->run($input); -echo json_encode($response->serialize()); +header('ContentType: application/json'); +echo $response->serialize(); diff --git a/examples/postInput.php b/examples/postInput.php new file mode 100644 index 0000000..b2d7e25 --- /dev/null +++ b/examples/postInput.php @@ -0,0 +1,30 @@ +registerForMethod('sampleMethod', $sampleHandler); + +$server = new JsonRpcServer( + $handler +); + +$response = $server->run($input); + +header('ContentType: application/json'); +echo $response->serialize();