Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/essential/life-cycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ import { validateSession } from './user'
new Elysia()
.get('/', () => 'hi', {
beforeHandle({ set, cookie: { session }, status }) {
if (!validateSession(session.value)) return status(401)
if (!validateSession(session.value)) return status('Unauthorized')
}
})
.listen(3000)
Expand All @@ -527,7 +527,7 @@ new Elysia()
.guard(
{
beforeHandle({ set, cookie: { session }, status }) {
if (!validateSession(session.value)) return status(401)
if (!validateSession(session.value)) return status('Unauthorized')
}
},
(app) =>
Expand Down
2 changes: 2 additions & 0 deletions docs/patterns/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ new Elysia()
})
```

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.

<Playground
:elysia="demo"
/>