-
Notifications
You must be signed in to change notification settings - Fork 0
Response
John Aldrich Bernardo edited this page Jan 28, 2018
·
3 revisions
Set response value.
<?php
$home = new \Calf\HTTP\Route('/', function($req, $res) {
return $res->set('Hello World!');
});Hello World!
Setting array response...
<?php
$home = new \Calf\HTTP\Route('/', function($req, $res) {
return $res->set(['message' => 'Hello World!']);
});{"message":"Hello World!"}
Get response value.
-
$raw:boolean- Get raw value
<?php
$home = new \Calf\HTTP\Route('/', function($req, $res) {
$res->set(['message' => 'Hello World!']);
return $res->get(true);
});array(1) { ["message"] => string(12) "Hello World!" }
Set HTTP Header(s).
-
$headers:mixed- Header or headers to be set
$res->setHeader("Content-Disposition: attachment");Return headers set in the response.
Set cookie(s) in the response.
<?php
$home = new \Calf\HTTP\Route('/', function($req, $res) {
$res->set(['message' => 'Hello World!']);
$res->setCookie(['Hello'=>'World']);
return $res->get(true);
});Return cookies set in the response.
Compress output (gzip).
Set response headers and cookies, and print response text.
The calf is open-sourced software licensed under the MIT license.