mirror of
https://github.com/aljazceru/ditto.git
synced 2025-12-18 05:54:23 +01:00
fetchWorker: support RequestInit
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { Comlink } from '@/deps.ts';
|
||||
|
||||
import './handlers/abortsignal.ts';
|
||||
|
||||
import type { FetchWorker } from './fetch.worker.ts';
|
||||
|
||||
const _worker = Comlink.wrap<typeof FetchWorker>(
|
||||
@@ -9,10 +11,10 @@ const _worker = Comlink.wrap<typeof FetchWorker>(
|
||||
),
|
||||
);
|
||||
|
||||
const fetchWorker: typeof fetch = async (input) => {
|
||||
const fetchWorker: typeof fetch = async (input, init) => {
|
||||
const { signal, ...rest } = init || {};
|
||||
const url = input instanceof Request ? input.url : input.toString();
|
||||
|
||||
const args = await _worker.fetch(url);
|
||||
const args = await _worker.fetch(url, rest, signal);
|
||||
return new Response(...args);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user