0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-22 11:17:33 +01:00
hono/benchmarks/webapp/itty-router.js

26 lines
1.0 KiB
JavaScript
Raw Normal View History

2021-12-28 00:51:05 +01:00
import { Router } from 'itty-router'
const ittyRouter = Router()
ittyRouter.get('/user', () => new Response('User'))
ittyRouter.get('/user/comments', () => new Response('User Comments'))
ittyRouter.get('/user/avatar', () => new Response('User Avatar'))
ittyRouter.get('/user/lookup/email/:address', () => new Response('User Lookup Email Address'))
ittyRouter.get('/event/:id', () => new Response('Event'))
ittyRouter.get('/event/:id/comments', () => new Response('Event Comments'))
ittyRouter.post('/event/:id/comments', () => new Response('POST Event Comments'))
ittyRouter.post('/status', () => new Response('Status'))
2022-05-26 02:09:01 +02:00
ittyRouter.get(
'/very/deeply/nested/route/hello/there',
() => new Response('Very Deeply Nested Route')
)
2021-12-28 00:51:05 +01:00
ittyRouter.get('/user/lookup/username/:username', ({ params }) => {
return new Response(`Hello ${params.username}`, {
status: 200,
headers: {
'Content-Type': 'text/plain;charset=UTF-8',
},
})
})
addEventListener('fetch', (event) => event.respondWith(ittyRouter.handle(event.request)))