Skip to content

Instantly share code, notes, and snippets.

@hskrasek
Created November 9, 2017 17:03
Show Gist options
  • Save hskrasek/ce3d67266cc8e1195b340f6d1175715a to your computer and use it in GitHub Desktop.
Save hskrasek/ce3d67266cc8e1195b340f6d1175715a to your computer and use it in GitHub Desktop.
Sunset Laravel
<?php
class APIController
{
uses SunsetsEndpoints;
public function index()
{
return $this->sunsetResponse($apiResponse, 'really cool date here');
}
}
<?php
trait SunsetsEndpoints
{
/**
* @return \Illuminate\Http\Response
*/
public function sunsetResponse(Response $response, $date, $link = null): Response
{
return tap($response, function (Response $response) use ($date, $link) {
$response->headers->add('Sunset', $date);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment