MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / wrapSubAppMiddleware

Function wrapSubAppMiddleware

packages/hono/src/shared/patchRoute.ts:118–137  ·  view source on GitHub ↗
(routes: HonoRoute[])

Source from the content-addressed store, hash-verified

116 * See: https://github.com/honojs/hono/blob/18fe604c8cefc2628240651b1af219692e1918c1/src/hono-base.ts#L156-L168
117 */
118export function wrapSubAppMiddleware(routes: HonoRoute[]): void {
119 const lastIndexByKey = new Map<string, number>();
120 for (const [i, route] of routes.entries()) {
121 // \0 (null byte) is a collision-free delimiter: it cannot appear in a valid HTTP method name or URL path
122 lastIndexByKey.set(`${route.method}\0${route.path}`, i);
123 }
124
125 for (const [i, route] of routes.entries()) {
126 if (typeof route.handler !== 'function') {
127 continue;
128 }
129
130 const isLastForGroup = lastIndexByKey.get(`${route.method}\0${route.path}`) === i;
131
132 const isMW = !isLastForGroup || (route.method === 'ALL' && isMiddleware(route.handler));
133 if (isMW) {
134 route.handler = wrapMiddlewareWithSpan(route.handler);
135 }
136 }
137}

Callers 2

applyPatchesFunction · 0.90
createRouteHookFunction · 0.85

Calls 5

isMiddlewareFunction · 0.90
wrapMiddlewareWithSpanFunction · 0.90
entriesMethod · 0.65
setMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected