Skip to content
Open
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
11 changes: 10 additions & 1 deletion docs/tutorial/getting-started/status-and-headers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,19 @@ You can also return a status code by returning your response using a `status` fu
import { Elysia } from 'elysia'

new Elysia()
.get('/', ({ status }) => status(418, "I'm a teapot'"))
.get('/', ({ status }) => status(418, "I'm a teapot"))
.listen(3000)
```

The status code can be a number or a string status name. Both of these are equivalent:

```typescript
status(418, "I'm a teapot")
status("I'm a teapot", "I'm a teapot")
```

String status names provide TypeScript autocompletion for all valid HTTP statuses.

See <DocLink href="/essential/handler#status">Status</DocLink>.

## Redirect
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/patterns/error-handling/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ new Elysia()
if(code === "NOT_FOUND")
return 'uhe~ are you lost?'

return status(418, "My bad! But I\'m cute so you'll forgive me, right?")
return status(418, "My bad! But I'm cute so you'll forgive me, right?")
})
.get('/', () => 'ok')
.listen(3000)
Expand Down