routes icon indicating copy to clipboard operation
routes copied to clipboard

ability to change HTTP status code within load() method?

Open columbian-chris opened this issue 3 years ago • 0 comments

Example:

Add to functions.php:

Routes::map('hello/world', function( $params ) {
	Routes::load('hello-world.php');
});

hello-world.php:

<?php
http_response_code(502);
die('hello world');

The browser shows a 200 response code, not a 502 as attempted within the route (hello-world.php). Obviously the Routes::load() method throws a 200 by default (which can be changed by passing a different code as the fourth parameter), but I'm wondering - is there a way that I can customize the status code within the loaded route?

columbian-chris avatar Jul 28 '21 16:07 columbian-chris