Skip to content

Commit f960ccc

Browse files
committed
docs(essential): clarify status accepts both number and string names
- Remove '// or' comments from teapot examples - Add explanatory note about 418 = 'I'm a teapot' with link to status tutorial - Use status("Unauthorized") for auth examples (clearer than 401)
1 parent 5e5da8b commit f960ccc

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

docs/essential/life-cycle.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ import { validateSession } from './user'
502502
new Elysia()
503503
.get('/', () => 'hi', {
504504
beforeHandle({ set, cookie: { session }, status }) {
505-
if (!validateSession(session.value)) return status(401)
505+
if (!validateSession(session.value)) return status("Unauthorized")
506506
}
507507
})
508508
.listen(3000)
@@ -527,7 +527,7 @@ new Elysia()
527527
.guard(
528528
{
529529
beforeHandle({ set, cookie: { session }, status }) {
530-
if (!validateSession(session.value)) return status(401)
530+
if (!validateSession(session.value)) return status("Unauthorized")
531531
}
532532
},
533533
(app) =>

docs/patterns/error-handling.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ new Elysia()
308308
})
309309
```
310310

311+
Here we use `status(418)` which is the "I'm a teapot" status code. You can also use the string name directly: `status("I'm a teapot")`. See [Status and Headers](/tutorial/getting-started/status-and-headers) for more on using status codes.
312+
311313
<Playground
312314
:elysia="demo"
313315
/>

0 commit comments

Comments
 (0)