diff --git a/.gitignore b/.gitignore index 7faad1c..6d0ff11 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,4 @@ Thumbs.db **/.env **/.dev.vars -**/wrangler.toml +wrangler.toml diff --git a/functions/_middleware.ts b/functions/_middleware.ts index 8a3ef86..5570ad6 100644 --- a/functions/_middleware.ts +++ b/functions/_middleware.ts @@ -1,6 +1,6 @@ import { index401 } from './util'; import { parse, stringify, validate } from 'uuid'; -const skipUrls = ['ws', 'assets']; +const skipUrls = ['ws', 'assets', 'http2']; async function errorHandling(context: EventContext) { try { diff --git a/functions/http2.ts b/functions/http2.ts new file mode 100644 index 0000000..8d781e6 --- /dev/null +++ b/functions/http2.ts @@ -0,0 +1,18 @@ +interface Env { + KV: KVNamespace; +} + +export const onRequest: PagesFunction = async (context) => { + const transformStream = + context.request.body?.pipeThrough(new TextDecoderStream()).pipeThrough( + new TransformStream({ + transform(chunk, controller) { + console.log('test'); + controller.enqueue(new TextEncoder().encode('xxxxx')); + }, + }) + ) || 'default'; + return new Response(transformStream, { + headers: { 'content-type': 'text/plain' }, + }); +};