go-toolkit icon indicating copy to clipboard operation
go-toolkit copied to clipboard

Add more functions to CompressedResource

Open chocolatkey opened this issue 1 year ago • 0 comments

Previously, the CompressedResource interface was added, to possibly stream resources in their original compressed format, to avoid having to decompress responses server-side before sending to the client.

This PR adds the ReadCompressed function to that interface, so that resources are not just streamed, but can also be read as a []byte in compressed form.

It also now adds GZIP versions of the stream/read functions directly in the toolkit, to make sending responses to clients that do not support deflate possible. This is particularly useful when placing the server behind a CDN like Cloudflare, that does not send deflate in its accept-encoding header.

chocolatkey avatar Sep 20 '24 23:09 chocolatkey