Welcome Guest, Not a member yet? Register   Sign In
Customizable 404 Error Pages for Specific Routes
#6

Your implementation uses 404Override for more than just 404. I think that's a bad idea.
405 is not 404. It's confusing to have setCustom404ForRoute() handle 405.

Also, such implementations that dynamically override 404Override cannot be cached.
There is currently no feature to cache defined routes, but if the number of routes becomes large, it would be better to cache them to improve performance.

I still recommend the implementation like this:

PHP Code:
// Normal route
$routes->post(
    'api/v1/ticket-history/record-change',
    'TicketHistoryController::recordChange'
);
// For 405 error
$routes->match(
    ['GET''DELETE''PUT'],
    'api/v1/ticket-history/record-change',
    'Datamweb\BlankCI\Controllers\Errors::show405'
); 

or add a new method to generate such routes internally.
E.g.,
PHP Code:
$routes->method(
    ['POST'// Allowed methods
    'api/v1/ticket-history/record-change',
    'TicketHistoryController::recordChange',
    'Datamweb\BlankCI\Controllers\Errors::show405'// Controller for errors
); 
Reply


Messages In This Thread
RE: Customizable 404 Error Pages for Specific Routes - by kenjis - 08-23-2024, 12:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB