add uuid into path

This commit is contained in:
zizifn
2023-05-19 22:04:31 +08:00
committed by zizifn
parent a7ed1d77f0
commit 4fde353447
8 changed files with 58 additions and 17 deletions

28
functions/sample/http2.ts Normal file
View File

@@ -0,0 +1,28 @@
interface Env {
KV: KVNamespace;
}
export const onRequest: PagesFunction<Env> = async (context) => {
let count = 0;
console.log('test11', Date.now());
await new Promise((resolve, rej) => {
setTimeout(() => {
resolve('');
}, 100);
});
console.log('test11', Date.now());
const transformStream =
context.request.body?.pipeThrough(new TextDecoderStream()).pipeThrough(
new TransformStream({
transform(chunk, controller) {
console.log('test', Date.now());
controller.enqueue(
new TextEncoder().encode(`${chunk} + ${count++} ${new Date()}`)
);
},
})
) || 'default';
return new Response(transformStream, {
headers: { 'content-type': 'text/plain' },
});
};