Mercurial
comparison benchmark/bun-http-framework-benchmark/src/bun/byte.ts @ 185:dfdd66825396
Merged in keep alive changes and mrjunejune changes.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Fri, 23 Jan 2026 22:22:30 -0800 |
| parents | a8976a008a9d |
| children |
comparison
equal
deleted
inserted
replaced
| 182:d6ab5921fedc | 185:dfdd66825396 |
|---|---|
| 1 import { Byte, query, send } from '@bit-js/byte' | |
| 2 | |
| 3 const xPoweredBy = ['X-Powered-By', 'benchmark'] as [string, string] | |
| 4 | |
| 5 // Extract the 'name' parameter value from query | |
| 6 const getName = query.get('name') | |
| 7 | |
| 8 // Serve directly | |
| 9 export default new Byte() | |
| 10 .get('/', send.body('Hi')) | |
| 11 // Send ID with query | |
| 12 .get('/id/:id', (ctx) => { | |
| 13 ctx.headers.push(xPoweredBy) | |
| 14 return ctx.body(`${ctx.params.id} ${getName(ctx)}`) | |
| 15 }) | |
| 16 // Yield body | |
| 17 .post('/json', async (ctx) => ctx.json(await ctx.req.json())) |