diff --git a/docs/tutorial/getting-started/life-cycle/index.md b/docs/tutorial/getting-started/life-cycle/index.md index c11381dd..a2064fed 100644 --- a/docs/tutorial/getting-started/life-cycle/index.md +++ b/docs/tutorial/getting-started/life-cycle/index.md @@ -62,6 +62,8 @@ new Elysia() .get('/2', () => 'Hello 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 for more on using status codes. + When `beforeHandle` returns a value, it will skip the handler and return the value instead. This is useful for things like authentication, where you want to return a `401 Unauthorized` response if the user is not authenticated. @@ -147,7 +149,7 @@ import { Elysia } from 'elysia' new Elysia() .onBeforeHandle(({ query: { name }, status }) => { - if(!name) return status(401) + if(!name) return status('Unauthorized') }) .get('/auth', ({ query: { name = 'anon' } }) => { return `Hello ${name}!`