examples icon indicating copy to clipboard operation
examples copied to clipboard

Route issue in route example

Open socketopp opened this issue 3 years ago • 1 comments

Hi, Good job on Hono!

Followed this hono-example-blog example.

The route will become /post/post, not /post.

Index.ts should have this instead, think it would fix it.

app.route('/', middleware)
app.route('/', api)

Am I wrong? Please explain to me in that case how you're suppose to you app.route correct.

socketopp avatar Oct 06 '22 18:10 socketopp

Hi @socketopp !

In that example, the route will become /api/posts. The path /posts will be appended to the path /api specified in route, and they will be merged:

api.get('/posts', (c) => c.text('Hi'))

//...

app.route('/api', api) // GET /api/posts => Hi

yusukebe avatar Oct 13 '22 11:10 yusukebe