0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-22 02:27:49 +01:00
hono/benchmarks/deno/hono-reg-exp-router.ts
2022-07-06 11:07:43 +09:00

20 lines
888 B
TypeScript

import { serve } from 'https://deno.land/std@0.146.0/http/server.ts'
import { Hono, RegExpRouter } from '../../deno_dist/mod.ts'
const app = new Hono({ router: new RegExpRouter() })
app.get('/user', (c) => c.text('User'))
app.get('/user/comments', (c) => c.text('User Comments'))
app.get('/user/avatar', (c) => c.text('User Avatar'))
app.get('/user/lookup/email/:address', (c) => c.text('User Lookup Email Address'))
app.get('/event/:id', (c) => c.text('Event'))
app.get('/event/:id/comments', (c) => c.text('Event Comments'))
app.post('/event/:id/comments', (c) => c.text('POST Event Comments'))
app.post('/status', (c) => c.text('Status'))
app.get('/very/deeply/nested/route/hello/there', (c) => c.text('Very Deeply Nested Route'))
app.get('/user/lookup/username/:username', (c) => {
return c.json({ message: `Hello ${c.req.param('username')}` })
})
serve((req) => app.fetch(req))