You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
652 B
PHP
30 lines
652 B
PHP
<?php
|
|
|
|
namespace BSR\Webservice;
|
|
|
|
use BSR\Webservice\Formatter\Formatter;
|
|
|
|
class Renderer {
|
|
private static $statusMessages = array(
|
|
200 => 'Ok',
|
|
400 => 'Bad request',
|
|
404 => 'Not Found',
|
|
403 => 'Not Authorized',
|
|
500 => 'Server Error',
|
|
);
|
|
|
|
public function __construct() {
|
|
ob_start();
|
|
}
|
|
|
|
public function render($status, $data) {
|
|
header(sprintf('HTTP/1.0 %s %s', $status, self::$statusMessages[$status]));
|
|
header("Access-Control-Allow-Origin: *");
|
|
ob_clean();
|
|
flush();
|
|
|
|
$formatter = Formatter::getFormatter();
|
|
$formatter->render($data);
|
|
}
|
|
}
|