Cloudflare Worker 的 Handler 函数
Handler 是 worker 的事件响应函数。
fetch 函数
fetch 函数响应外部的 HTTP 请求。
requestRequest:The incoming HTTP request.envobject:The bindings available to the Worker.ctx.waitUntil(promisePromise): void 回复响应后,依然会执行的 Promisectx.passThroughOnException(): void
scheduled 函数
export default {
async scheduled(controller, env, ctx) {
return await fetch("https://example.com", {
headers: {
"X-Source": "Cloudflare-Workers",
},
});
},
};
controller.cronstring:The value of the Cron Trigger that started theScheduledEvent.controller.typestring:The type of controller. This will always return"scheduled".controller.scheduledTimenumber:The time theScheduledEventwas scheduled to be executed in milliseconds since January 1, 1970, UTC. It can be parsed asnew Date(controller.scheduledTime).