@fly/cdn
Version:
Fly's TypeScript CDN
25 lines (24 loc) • 702 B
TypeScript
import { FetchFunction } from "../fetch";
/**
* Automatically encodes images as webp for supported clients.
* This would apply to requests with 'image/webp' in the accept header
* and 'image/jpeg' or 'image/png' in the response type from origin.
*
* Example:
*
* ```typescript
* import { origin } from "./src/backends";
* import { autoWebp } from "./src/middleware/auto-webp";
*
* const backend = origin({
* origin: "https://fly.io/",
* headers: {host: "fly.io"}
* })
*
* const images = autoWebp(backend);
*
* fly.http.respondWith(images);
* ```
*/
export declare function autoWebp(fetch: FetchFunction): FetchFunction;
export declare function webpAllowed(req: Request): boolean;