You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(error-handling): split 404 and 405 default responses
- Add 405 Method Not Allowed section with Allow header example
- Note HEAD is added automatically when a GET handler exists
- Scope 404 to paths matching no route pattern
Copy file name to clipboardExpand all lines: docs/id/error-handling/default-behavior.md
+15-3Lines changed: 15 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@ Penanganan error default mencakup semua jenis error yang bisa terjadi selama pem
52
52
53
53
### 404 - Rute Tidak Ditemukan
54
54
55
-
Ketika rute tidak ada atau tidak ada route handler yang cocok:
55
+
Ketika tidak ada rute yang cocok dengan path request sama sekali:
56
56
57
57
```typescript
58
58
// GET /nonexistent
@@ -64,8 +64,20 @@ Ketika rute tidak ada atau tidak ada route handler yang cocok:
64
64
Ini mencakup:
65
65
66
66
- Rute yang tidak ada
67
-
- Rute dengan metode HTTP yang salah
68
-
- Rute yang gagal cocok saat resolusi routing
67
+
- Path yang tidak cocok dengan pola mana pun saat resolusi routing
68
+
69
+
### 405 - Metode Tidak Diizinkan
70
+
71
+
Ketika path cocok dengan sebuah rute tapi metodenya tidak punya handler, response-nya **405** dengan header `Allow` yang mendaftar metode yang didukung:
72
+
73
+
```typescript
74
+
// DELETE /users (hanya GET dan POST terdefinisi)
75
+
// Status: 405
76
+
// Body: JSON atau HTML (lewat header Accept)
77
+
// Headers: { Allow: "GET, HEAD, POST" }
78
+
```
79
+
80
+
`HEAD` ditambahkan otomatis setiap kali handler `GET` ada.
0 commit comments