Make 404 a exception instead of a response

Aperta
#115 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
php
Ambito
api, backend

Direzione di ricerca

Start with the exception handling documentation and the existing errorRoute behavior described in the issue. Trace how a 404 currently sends its header, then determine where the NotFound exception and default route belong. Done means 404 errors are catchable by type, can use route routines and content negotiation, and preserve current behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Using exception handling we can make errors catchable by type. If we treat the error as an usual route we can also attach routines to it so it can respect content negotiation (as mentioned on #109).

  • Throw Respect\Rest\Exception\Http\NotFound exception for 404 errors instead of just sending a header.
  • Create a default route to catch this exception, ensuring current behaviour is not affected.

Original issue content

I have a question about how to implement a error route for a Default 404 Not Found Page, but have not found the solution.
I created a class Error404 controller to display a standard html page, but it did not work:
$router->any('/**', 'Routes\Error404');
I also tried to use the method errorRoute, but without success.
$router->errorRoute($callback);
Is there a solution to this problem?

Thank's all to help me!

Lingua principale
PHP
Stelle
605
Fork
100
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Respect/Rest

Tutte le issue di Respect/Rest

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.