Skip to content
Myr

perf(context): add HonoResponse for better performance (#281)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Yusuke Wada · committed by GitHub · parent 8bbb495 · Browse files · 3 files+62 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+62 added−7 removed

  • other:+62 added−7 removed

3 files+62 added−7 removed

modified:src/context.ts+3 added-2 removed
modified:src/hono.ts+3 added-5 removed
1import { compose } from './compose'2import { Context } from './context'3import type { Env } from './context'4import type { Result, Router } from './router'5import { METHOD_NAME_ALL } from './router'6import { METHOD_NAME_ALL_LOWERCASE } from './router'5import { METHOD_NAME_ALL, METHOD_NAME_ALL_LOWERCASE } from './router'6import { TrieRouter } from './router/trie-router' // Default Router7import { getPathFromURL, mergePath } from './utils/url'89declare global {
74 unmodified lines
8485export class Hono<E = Env, P extends string = '/'> extends defineDynamicClass()<E, P, Hono<E, P>> {86 readonly router: Router<Handler<string, E>> = new TrieRouter()87 readonly strict: boolean = true // strict routing - default is true89 private _tempPath: string88 private _tempPath: string = ''89 private path: string = '/'9091 routes: Route<E>[] = []92
20 unmodified lines
113 }114 })115116 Object.assign(this, init)118119 this._tempPath = ''117 }118119 private notFoundHandler: NotFoundHandler = (c: Context) => {120 const message = '404 Not Found'
74 unmodified lines
195 }196 }197 return null198 }) as typeof request.param199200 const handlers = result ? result.handlers : [this.notFoundHandler]201202 const c = new Context<string, E>(request, {203 env: env,
39 unmodified lines
added:src/response.ts+56 added