2021-08-04 02:43:28 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
2021-08-04 14:05:00 +08:00
|
|
|
namespace Server\Constrict;
|
2021-08-04 02:43:28 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
use HttpServer\Http\Context;
|
2021-08-04 02:53:35 +08:00
|
|
|
use HttpServer\Http\Response as HttpResponse;
|
2021-08-04 17:13:26 +08:00
|
|
|
use Server\ResponseInterface;
|
2021-08-04 02:43:28 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class Response
|
|
|
|
|
* @package Server
|
2021-08-04 10:16:03 +08:00
|
|
|
* @mixin HttpResponse
|
2021-08-04 02:43:28 +08:00
|
|
|
*/
|
2021-08-04 17:13:26 +08:00
|
|
|
class Response implements ResponseInterface
|
2021-08-04 02:43:28 +08:00
|
|
|
{
|
|
|
|
|
|
2021-08-04 10:16:03 +08:00
|
|
|
const JSON = 'json';
|
|
|
|
|
const XML = 'xml';
|
|
|
|
|
const HTML = 'html';
|
2021-08-10 16:40:01 +08:00
|
|
|
const FILE = 'file';
|
2021-08-04 10:16:03 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $name
|
|
|
|
|
* @param $args
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function __call($name, $args)
|
|
|
|
|
{
|
2021-08-13 16:39:44 +08:00
|
|
|
if (!Context::hasContext(HttpResponse::class)) {
|
|
|
|
|
$context = Context::setContext(HttpResponse::class, new HttpResponse());
|
|
|
|
|
} else {
|
|
|
|
|
$context = Context::getContext(HttpResponse::class);
|
|
|
|
|
}
|
|
|
|
|
return $context->{$name}(...$args);
|
2021-08-04 10:16:03 +08:00
|
|
|
}
|
2021-08-04 02:43:28 +08:00
|
|
|
|
|
|
|
|
}
|