ITADN

Simplify management of query parameters

#448Opendarrachequesne 创建于 2026-01-29
D
darrachequesnecommented
Hi! If I understand correctly, one can already extract the query parameters with `setRequestCallback()`: ```js // note: async is needed here, else an "Uncaught TypeError: this.requestHandler(...).then is not a function" exception is thrown h3Server.setRequestCallback(async ({ header }) => { const url = new URL(header[":path"], "https://example.com"); if (url.pathname === "/my-path/") { header[":path"] = url.pathname; // option 1: added on the header object header[":query"] = url.searchParams; return { path: url.pathname, header, status: 200, // option 2: added on the userData object userData: { query: url.searchParams } } } return { status: 404 }; }); ``` Is that right? In that case, do you think it would make sense to include them directly on the `HttpWTSession`? Thanks in advance. Related: https://github.com/fails-components/webtransport/issues/279
1 条评论