Skip to content

Instantly share code, notes, and snippets.

View Crell's full-sized avatar

Larry Garfield Crell

View GitHub Profile
function toJsonResponse(ApiProblem $problem, ResponseInterface $response)
{
$body = $response->getBody();
$body->rewind();
$body->write($problem->asJson($this->pretty));
return $this->toResponse($problem, $response)
->withHeader('Content-Type', 'application/problem+json')
->withBody($body);
<?php
namespace Crell\IcicleTest;
use Icicle\Http\Message\RequestInterface;
use Icicle\Http\Message\Response;
class Router
@Crell
Crell / AccessedPolicy.php
Last active August 29, 2015 14:26
Expiry cache extension
<?php
class AccessedPolicy implements PolicyInterface {
public function __construct($access_count) { /*...*/ }
}
<?php
class BigPipeResponse extends StreamedResponse {
public function __construct(Response $response) {
$this->mainResponse = $response;
$this->setStatusCode($response->statusCode());
$this->headers->set($response->headers->all());
$this->mainBody = $response->getContent();
}