Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom Content-Type for render.Data #16

Open
milesje opened this issue Jan 11, 2019 · 1 comment
Open

Allow custom Content-Type for render.Data #16

milesje opened this issue Jan 11, 2019 · 1 comment

Comments

@milesje
Copy link

milesje commented Jan 11, 2019

Quite often the response to my API is a file such as an image or pdf. It would be nice to be able to use render.Data and be able to set the Content-Type to something other than application/octet-stream.

To get around this limitation at the moment I use render.JSON or render.XML for sending back JSON or XML data and then fall back to useing http.ResponseWriter.Write for files.

It would be nice not to have to fall back to using the http.ResponseWriter and just use the render.Data to handle files.

@ptman
Copy link

ptman commented Aug 7, 2020

You could write a custom function that takes an extra parameter. It's not very complex: https://github.com/go-chi/render/blob/master/responder.go#L74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants