mirror of
https://github.com/lush2020/edgetunnel.git
synced 2026-03-24 00:48:39 +08:00
init cf worker code
This commit is contained in:
22
test/worker/cf-worker-http-header.js
Normal file
22
test/worker/cf-worker-http-header.js
Normal file
@@ -0,0 +1,22 @@
|
||||
export default {
|
||||
/**
|
||||
* @param {import("@cloudflare/workers-types").Request} request
|
||||
* @param {{uuid: string}} env
|
||||
* @param {import("@cloudflare/workers-types").ExecutionContext} ctx
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
async fetch(request, env, ctx) {
|
||||
const headers = {};
|
||||
for (const [name, value] of request.headers.entries()) {
|
||||
headers[name] = value;
|
||||
}
|
||||
|
||||
const result = {
|
||||
"http-header": headers,
|
||||
"cf": request.cf
|
||||
}
|
||||
const headersJson = JSON.stringify(result);
|
||||
console.log(headersJson);
|
||||
return new Response(headersJson, { status: 200 });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user