44 * @typedef {import("hono").Context } HonoContext
55 */
66
7+ /**
8+ * Hono 请求类型。
9+ * Hono request type.
10+ * @typedef {HonoContext["req"] } HonoRequest
11+ */
12+
713/**
814 * Worker 统一头部字典。
915 * Worker normalized header dictionary.
@@ -88,22 +94,22 @@ export default class HonoWorkerAdapter {
8894 }
8995
9096 /**
91- * 从 Hono context 构造内部统一请求对象。
92- * Build the normalized internal request payload from Hono context .
93- * @param {HonoContext } c Hono 上下文 / Hono context .
97+ * 从 Hono request 构造内部统一请求对象。
98+ * Build the normalized internal request payload from Hono request .
99+ * @param {HonoRequest } req Hono 请求 / Hono request .
94100 * @returns {Promise<WorkerRequest> } 标准化请求对象 / Normalized request object.
95101 */
96- static async buildRequest ( c ) {
97- const url = HonoWorkerAdapter . routeRewrite ( new URL ( c . req . url ) , c . req . param ( "rest" ) ) ;
98- const method = c . req . method ;
102+ static async buildRequest ( req ) {
103+ const url = HonoWorkerAdapter . routeRewrite ( new URL ( req . url ) , req . param ( "rest" ) ) ;
104+ const method = req . method ;
99105 let bodyBytes ;
100106 switch ( method ) {
101107 case "GET" :
102108 case "HEAD" :
103109 case "OPTIONS" :
104110 break ;
105111 default :
106- bodyBytes = await c . req . arrayBuffer ( ) . catch ( error => {
112+ bodyBytes = await req . arrayBuffer ( ) . catch ( error => {
107113 console . info ( error ) ;
108114 return undefined ;
109115 } ) ;
@@ -113,7 +119,7 @@ export default class HonoWorkerAdapter {
113119 return {
114120 method,
115121 url : url . toString ( ) ,
116- headers : HonoWorkerAdapter . normalizeRequestHeaders ( c . req . header ( ) ) ,
122+ headers : HonoWorkerAdapter . normalizeRequestHeaders ( req . header ( ) ) ,
117123 body : bodyBytes ,
118124 bodyBytes,
119125 } ;
0 commit comments