v3.0.2
Added ability to send custom header values with the response class
On the Request
class has been added a new method called header
which accepts 2 parameters:
$key
which can be of typestring
,array
orobject
and$value
which is of typemixed
with null being the default value
The return value of this method call is an instance of the Request
class so that the other methods can be chained on it as well
Example:
$routes->add("/headers", function (Request $request) {
$request->header("Content-type", "text/plain")
->header([ "foo" => "bar", "best" => "test" ])
->header((object) [ "X-Auth" => "Token {token-123}" ])
->status(201)
->send([ "message" => "hello" ]);
}, Routes::GET);