Skip to content

v3.0.2

Compare
Choose a tag to compare
@gigili gigili released this 26 Apr 21:39
· 55 commits to main since this release

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 type string, array or object and
  • $value which is of type mixed 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);