gleam-wisp / wisp

🧚 A practical web framework for Gleam
https://gleam-wisp.github.io/wisp/
Apache License 2.0
770 stars 36 forks source link

Add a convenient way of setting/adding charset in the HTTP content-type header of the Response #86

Closed stoft closed 2 months ago

stoft commented 2 months ago

For example text/html; charset=utf-8. Currently this requires a call to set_header but not forgetting to add the mime-type that may already be there.

lpil commented 2 months ago

Is there a reason we wouldn't always set the charset for HTML?

stoft commented 2 months ago

Not that I can think of but I'm no expert regarding http headers. Of note is that charset can be set for other text types as well, and application/json.

I'm also unsure of the ergonomics here, could it be utf-8 by default and then have some way of changing it such as "wisp.set_charset"? Or are there too many people out there for whom utf-8 would be just plain wrong?

lpil commented 2 months ago

Gleam uses utf-8 so the these bodies are guaranteed to be that charset. Let's add it to all of them