Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const zlib = require('zlib');
- const response = "{}"
- exports.handler = (event, context, callback) => {
- if (event.headers['Accept-Encoding'].contains("gzip")) {
- zlib.gzip(response, function(error, gzippedResponse) {
- if (error) callback(error);
- else callback(null, {
- "body": gzippedResponse.toString("base64"),
- "isBase64Encoded": true,
- "statusCode": 200,
- "headers": {
- "Content-Encoding": "gzip"
- }
- });
- }
- }
- else callback(null, {
- "body": response,
- "statusCode": 200,
- "headers": {}
- });
- }
Add Comment
Please, Sign In to add comment