mirror of
https://github.com/lush2020/edgetunnel.git
synced 2026-03-24 00:48:39 +08:00
test http2 in worker
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -44,4 +44,4 @@ Thumbs.db
|
|||||||
**/.env
|
**/.env
|
||||||
|
|
||||||
**/.dev.vars
|
**/.dev.vars
|
||||||
**/wrangler.toml
|
wrangler.toml
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { index401 } from './util';
|
import { index401 } from './util';
|
||||||
import { parse, stringify, validate } from 'uuid';
|
import { parse, stringify, validate } from 'uuid';
|
||||||
const skipUrls = ['ws', 'assets'];
|
const skipUrls = ['ws', 'assets', 'http2'];
|
||||||
|
|
||||||
async function errorHandling(context: EventContext<any, any, any>) {
|
async function errorHandling(context: EventContext<any, any, any>) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
18
functions/http2.ts
Normal file
18
functions/http2.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
interface Env {
|
||||||
|
KV: KVNamespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const onRequest: PagesFunction<Env> = 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' },
|
||||||
|
});
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user