Closed chez14 closed 4 years ago
It's not a bug. By design, you can override 404 only once, so the last call to the set404Override()
will define the method that will be used.
Got it. Thanks.
So basically you need to check the url it trying to access, and send the appropriate response in the mentioned method,... right?
Yes, depending on your application design - you might use the URI
service or search for specified headers.
Describe the bug When defining 404 override in group, it override global 404 overrides too.
Generally i want my API's 404 served under json format too.
CodeIgniter 4 version CodeIgniter v4.0.4 (via
composer create-project
)composer info
```shell ci4-routing-bug on master ❯ composer info codeigniter4/framework v4.0.4 The CodeIgniter framework v4 doctrine/instantiator 1.3.1 A small, lightweight utility... fzaninotto/faker dev-master 5337ce5 Faker is a PHP library that ... kint-php/kint 3.3 Kint - debugging tool for PH... laminas/laminas-escaper 2.6.1 Securely and safely escape H... laminas/laminas-zendframework-bridge 1.1.0 Alias legacy ZF class names ... mikey179/vfsstream v1.6.8 Virtual file system to mock ... myclabs/deep-copy 1.10.1 Create deep copies (clones) ... phar-io/manifest 1.0.3 Component for reading phar.i... phar-io/version 2.0.1 Library for handling version... phpdocumentor/reflection-common 2.2.0 Common reflection classes us... phpdocumentor/reflection-docblock 5.2.1 With this component, a libra... phpdocumentor/type-resolver 1.3.0 A PSR-5 based resolver of Cl... phpspec/prophecy 1.11.1 Highly opinionated mocking f... phpunit/php-code-coverage 7.0.10 Library that provides collec... phpunit/php-file-iterator 2.0.2 FilterIterator implementatio... phpunit/php-text-template 1.2.1 Simple template engine. phpunit/php-timer 2.1.2 Utility class for timing phpunit/php-token-stream 3.1.1 Wrapper around PHP's tokeniz... phpunit/phpunit 8.5.8 The PHP Unit Testing framework. psr/log 1.1.3 Common interface for logging... sebastian/code-unit-reverse-lookup 1.0.1 Looks up which function or m... sebastian/comparator 3.0.2 Provides the functionality t... sebastian/diff 3.0.2 Diff implementation sebastian/environment 4.2.3 Provides functionality to ha... sebastian/exporter 3.1.2 Provides the functionality t... sebastian/global-state 3.0.0 Snapshotting of global state sebastian/object-enumerator 3.0.3 Traverses array structures a... sebastian/object-reflector 1.1.1 Allows reflection of object ... sebastian/recursion-context 3.0.0 Provides functionality to re... sebastian/resource-operations 2.0.1 Provides a list of PHP built... sebastian/type 1.1.3 Collection of value objects ... sebastian/version 2.0.1 Library that helps with mana... symfony/polyfill-ctype v1.18.1 Symfony polyfill for ctype f... theseer/tokenizer 1.2.0 A small library for converti... webmozart/assert 1.9.1 Assertions to validate metho... ```Affected module(s) I guess it's the RoutingCollection class.
Expected behavior, and steps to reproduce if appropriate Step To Reproduce:
php spark serve
Expected behavior:
App\Controllers\Home::handle404
notApp\Controllers\Api\Generic::handle404
.Context
php:7.3-apache