-
Notifications
You must be signed in to change notification settings - Fork 0
Route Response
Joshua Parker edited this page Aug 21, 2020
·
2 revisions
Qubus Router supports the following responses.
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\Response\TextResponse;
use Laminas\Diactoros\Response\XmlResponse;
$router->get('/empty', function () {
return new EmptyResponse();
});
$router->get('/html/1', function () {
return '<html>This is an HTML response.</html>';
});
$router->get('/html/2', function () {
return new HtmlResponse(
'<html>This is another HTML response.</html>',
200,
['Content-Type' => ['application/xhtml+xml']]
);
});
$router->get('/json', function () {
return new JsonResponse(
'This is a JSON response.',
200,
['Content-Type' => ['application/hal+json']]
);
});
$router->get('/text', function () {
return new TextResponse(
'This is a text response.',
200,
['Content-Type' => ['text/csv']]
);
});
$router->get('/xml', function () {
return new XmlResponse(
'This is an xml response.',
200,
['Content-Type' => ['application/hal+xml']]
);
});