humanmade / tachyon

Faster than light image resizing service that runs on AWS. Super simple to set up, highly available and very performant.

Home Page:https://engineering.hmn.md/projects/tachyon/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example for WebPDetectionLambdaFunctionARN

reipan opened this issue · comments

Hey there,
i'm pretty new to that topic. Can you give me an example of a working lambda@edge function that enables webp detection in tachyon?

This is what we are running in production:

exports.handler = (event, context, callback) => {
	if (
		event.Records[0].cf.request.headers['accept'] &&
		event.Records[0].cf.request.headers['accept'][0].value.indexOf('image/webp') >
			-1
	)
		event.Records[0].cf.request.headers['x-webp'] = [{key:'X-WebP', value: '1'}];
	
	return callback(null, event.Records[0].cf.request);
};

Hope that helps!