h2non / imaginary

Fast, simple, scalable, Docker-ready HTTP microservice for high-level image processing
https://fly.io/docs/app-guides/run-a-global-image-service/
MIT License
5.5k stars 455 forks source link

Adding support for response headers #422

Open EyePulp opened 7 months ago

EyePulp commented 7 months ago

We use imaginary upstream from an nginx cache, and would like for nginx to receive the cache-control response header from the http sources that imaginary is pulling from. In our case S3 and Google Cloud Storage, where we can set the cache-control value when the image is stored there.

It appears currently that imaginary just returns the image buffer / body content from the http.Response, and doesn't pass through the response headers.

We don't want to use -http-cache-ttl as that doesn't accurately reflect the cache-control needs of the source images.

I'm working on a PR that works similarly to the -forward-headers argument, except for url response headers. The idea being that users can decide what headers if any they want passed back from a response, e.g.:

/bin/imaginary -enable-url-source -return-response-headers cache-control,etag

I'm new to Golang and may need some help, but I'll get a PR together. Please let me know if you have concerns or recommendations.

Thanks!