Restricting bearer auth to route + HTTP verb? #793
Answered
by
yusukebe
VirtualWolf
asked this question in
Q&A
-
Hi! I'm playing around with Hono on Cloudflare and it seems very slick, nice work. :) One thing I haven't been able to figure out is how to add bearer auth to a specific route and a specific HTTP verb combination. So say I have an API at Many thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
yusukebe
Jan 9, 2023
Replies: 2 comments 6 replies
-
Hi @VirtualWolf ! You can write like the following: app.get('/api/posts', (c) => {
return c.text('Read Posts!')
})
app.post('/api/post', bearerAuth({ token: 'foo' }), (c) => {
return c.text('Post Created!', 201)
}) |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
VirtualWolf
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @VirtualWolf !
You can write like the following: