Skip to content

Commit

Permalink
Add new grouping example (honojs#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego authored Apr 6, 2024
1 parent 9af5505 commit 12eb5a2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions api/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@ const app = new Hono()
app.route('/book', book)
```

## Grouping without changing base

You can also group multiple instances while keeping base.

```ts
const book = new Hono()
book.get('/book', (c) => c.text('List Books')) // GET /book
book.post('/book', (c) => c.text('Create Book')) // POST /book

const user = new Hono().basePath('/user')
user.get('/user', (c) => c.text('List Users')) // GET /user
user.post('/user', (c) => c.text('Create User')) // POST /user

const app = new Hono()
app.route('/', book) // Handle /book
app.route('/', user) // Handle /user
```

## Base path

You can specify the base path.
Expand Down

0 comments on commit 12eb5a2

Please sign in to comment.